The
choice group element allows only one of its children to appear in an instance. One child is an inner
group element that references the named group
shipAndBill consisting of the element sequence
shipTo,
billTo, and the second child is a
singleUSAddress. Hence, in an instance document, the
purchaseOrder element must contain EITHER
a shipTo element followed by a billTo element OR a
singleUSAddress element. The choice group is followed by the comment and items element declarations, and both the
choice group and the element declarations are children of a
sequence group. The effect of these various groups is that the address element(s) must be followed by comment and items elements in that order.
<xsd:complexType name="PurchaseOrderType">`
<xsd:sequence>
<xsd:choice>
<xsd:group ref="shipAndBill"/>
<xsd:element name="singleUSAddress" type="USAddress"/>
</xsd:choice>
<xsd:element ref="comment" minOccurs="0"/>
<xsd:element name="items" type="Items"/>
</xsd:sequence>
<xsd:attribute name="orderDate" type="xsd:date"/>
</xsd:complexType>
<xsd:group name="shipAndBill">
<xsd:sequence>
<xsd:element name="shipTo" type="USAddress"/>
<xsd:element name="billTo" type="USAddress"/>
</xsd:sequence>
</xsd:group>
Reference:
http://www.w3.org/TR/2001/REC-xmlschema-0-20010502/
No comments:
Post a Comment