slide 31

XSD Choice

(In DTD syntax: <!ELEMENT name ((given, family) | (family, given)) > )

<xs:complexType name="name.type">
  <xs:choice>
    <xs:sequence>
      <xs:element ref="given"/>
      <xs:element ref="family"/>
    </xs:sequence>
    <xs:sequence>
      <xs:element ref="family"/>
      <xs:element ref="given"/>
    </xs:sequence>
  </xs:choice>
</xs:complexType>

<xs:element name="given" type="xs:string"/>

<xs:element name="family" type="xs:string"/>

<xs:element name="name" type="name.type"/>

Validates both
<name><given>John</given><family>Wayne</family></name>
and
<name><family>Mifune</family><given>Toshiro</given></name>