XML technologies / XML Schema / XML Schema element reference / xs:union

(Excerpt from “XML Schema” by Eric van der Vlist)

Deriving simple data types by union.

<xs:union
    id = xs:ID
    memberTypes = list of xs:QName
    {beliebige Attribute mit einem Nicht-Schema-Namensraum}
    >
    Content: ((xs:annotation?), (xs:simpleType*))
</xs:union>

May occur within: xs:simpleType (local definition), xs:simpleType (global definition)

Description

Deriving a simple data type by union mixes the lexical spaces of several simple data types, called member types, to create a new simple data type.

Regardless of the member types’ variety, atomic, list or union, the resulting data type has variety union.

Member types can be defined by reference, using attribute memberTypes, or embedded as locally defined data types within element xs:union. Both styles can be mixed.

The semantics of member data types are lost for validation, and the only facets subsequently applicable to the resulting data type are xs:pattern and xs:enumeration.

However, these semantics are not entirely lost to an application using the PSVI, since the validator must canonicalize according to the first member type matching the instance value. The order of the member-type list therefore matters. If both styles are used, types referenced in memberTypes are tested before locally defined types.

Restrictions

None.

Example

<xs:simpleType name="integerOrData">
    <xs:union memberTypes="xs:integer xs:data"/>
</xs:simpleType>

Attributes

id
Element ID according to W3C XML Schema.

memberTypes
List of member types; member types can also be embedded as xs:simpleType within element xs:union.

   

 

 

 

back to top