Element union w XML Schema

Definicja i użycie

Element union definiuje zbiór wielu typów prostych zdefiniowanych przez simpleType.

Informacje o elemencie

Wystąpienia Jednokrotne
Rodzic simpleType
Zawartość annotation, simpleType

Gramatyka

<union
id=ID
memberTypes="lista QNameów"
Każde atrybuty
>
(annotation?,(simpleType*))
</union>

(? Symbol oznacza, że element może występować zero lub jeden raz w elemencie union.)

Atrybuty Opis
id Opcjonalnie. Określa unikalny ID elementu.
memberTypes Opcjonalnie. Określa listę nazw wbudowanych typów danych lub elementów simpleType zdefiniowanych w schemacie.
Każde atrybuty Opcjonalnie. Określa każdą inną właściwość z non-schema namespace.

Przykład

Przykład 1

Ten przykład jest złożonym typem prostym, który łączy dwa inne typy prostsze:

<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>