XML Schema union element

Definition and Usage

Ang union element ay nagtataglay ng kumbinasyon ng mga simpleType na tinukoy.

Element Information

Number of Occurrences Once
Parent Element simpleType
Content annotation, simpleType

Grammar

<union
id=ID
memberTypes="list of QNames"
anumang attributes
>
(annotation?,(simpleType*))
</union>

(? simbolo ay ipinapahayag sa union element na ang element na ito ay maaaring lumitaw na walang beses o isang beses.)

Attribute Paglalarawan
id Opsiyonal. Tukuyin ang tanging ID ng element na ito.
memberTypes Opsiyonal. Tukuyin ang listahan ng pangalan ng mga nakalagay sa schema na mga data type o simpleType element.
anumang attributes Opsiyonal. Tukuyin ang kahit anong ibang attribute na may non-schema na pangalan ng namespace.

Mga halimbawa

Halimbawa 1

Ang kasong ito ay isang simple type na pinagsama-sama ang dalawang simple type:

<xs:element name="jeans_size">
  <xs:simpleType>
    <xs:union memberTypes="sizebyno sizebystring" />
  </xs:simpleType>
</xs:element>
<xs:simpleType name="sizebyno">
  <xs:restriction base="xs:positiveInteger">
    <xs:maxInclusive value="42"/>
  </xs:restriction>
</xs:simpleType>
<xs:simpleType name="sizebystring">
  <xs:restriction base="xs:string">
    <xs:enumeration value="small"/>
    <xs:enumeration value="medium"/>
    <xs:enumeration value="large"/>
  </xs:restriction>
</xs:simpleType>