Reputation: 4917
Is there any way in xsd we can restrict/limit the xsd:choice.
My requirement is if status tag have value "Accepted" then next tag must be "Accepted" or same in the case of others Reject-> Reject and Paid->Paid
XSD is
<xsd:element name="Status" minOccurs="1">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:enumeration value="Reject" />
<xsd:enumeration value="Accepted" />
<xsd:enumeration value="Paid" />
</xsd:restriction>
</xsd:simpleType>
</xsd:element>
<xsd:choice>
<xsd:element name="Reject" type="CommentsOnly" minOccurs="0"/>
<xsd:element name="Accepted" type="AcceptanceOrPaid" minOccurs="0"/>
<xsd:element name="Paid" type="AcceptanceOrPaid" minOccurs="0"/>
</xsd:choice>
Upvotes: 0
Views: 44
Reputation: 163262
In any situation where the validation rules for one element depend on the content of previous elements, you need XSD 1.1 assertions.
XSD 1.1 is supported by Altova, Saxon, and Xerces, but not (for example) by Microsoft's schema processor.
Upvotes: 1