I am creating an XSD for the following XML structure:
<BaseNode>
<ParentNode1>
<childnode/>
</ParentNode1>
<ParentNode2>
<childnode/>
</ParentNode2>
<ParentNodeA>
<childnode/>
</ParentNodeA>
<ParentNodeB>
<childnode/>
</ParentNodeB>
</BaseNode>
Where: ParentNodes 1 and 2 must appear and in order, and A and B are optional (and will only appear once each, if present), but must appear after 1 and 2 if present.
What I ‘think’ will work is the following, but is it valid? (specifically, the presence of both, sequence and all Order Indicators)
<xs:element name="BaseNode">
<xs:complexType>
<xs:sequence>
<xs:element name="ParentNode1">
....
</xs:element>
<xs:element name="ParentNode2">
....
</xs:element>
</xs:sequence>
<xs:all>
<xs:element name="ParentNodeA">
....
</xs:element>
<xs:element name="ParentNodeB">
....
</xs:element>
</xs:all>
</xs:comlexType>
</xs:element>
I couldn’t find any reference (in w3schools.com or elsewhere) to compound use of order indicators, and don’t have a validator readily available.
Thank you in advance.
I found the answer at http://www.w3.org/TR/xmlschema-0/#groups
example provided at the link.