XML Schema union element
Definition and usage
The union element defines a collection of simpleType definitions.
Element information
Occurrence times | One |
Parent element | simpleType |
Content | annotation, simpleType |
Syntax
<union id=ID memberTypes="list of QNames" any attributes > (annotation?,(simpleType*)) </union>
(The '?' symbol indicates that the element can occur zero or one times within the union element.)
Attribute | 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. |
Instance
Example 1
This example is a simple type that merges 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>