XML Schema unionElement
Complete XML Schema Reference Manual
Definition and Usage
The union element defines a collection of multiple simpleType definitions.
Element Information
- Parent element: simpleType
Syntax
<union
id=ID
memberTypes="list of QNames"
any attributes
>
(annotation?,(simpleType*))
</union>
id=ID
memberTypes="list of QNames"
any attributes
>
(annotation?,(simpleType*))
</union>
(The ? sign declares that the element can appear zero or one time within the union element.)
| Attributes | Description |
|---|---|
| id | Optional. Specifies a unique ID for the element. |
| memberTypes | Optional. Specifies a list of names of built-in data types or simpleType elements defined in the schema. |
| any attributes | Optional. Specifies any other attributes with a non-schema namespace. |
Example 1
This example is a simple type that combines two simple types:
<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>
<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>
Complete XML Schema Reference Manual Other Extensions