Name

xs:union — Derivation of simple datatypes by union.

Synopsis

<xs:union
           id          = xs:ID
           memberTypes = list of xs:QName
           {any attributes with non-schema namespace}
           >
           Content: ((xs:annotation?), (xs:simpleType*))
</xs:union>

May be included in: xs:simpleType (local definition), xs:simpleType (global definition)

Description

Deriving a simple datatype by union merges the lexical spaces of several simple datatypes (called member types) to create a new simple datatype.

Whatever the type (atomic, list, or union) of the member types, the resulting datatype has a type union.

The member types can be defined either by reference (through the memberTypes attribute) or embedded as simple datatype local definitions in the xs:union element. Both styles can be mixed.

The semantic of the member datatypes is lost at least as far as validation is concerned, and the only facets that can be further applied to the resulting datatype are xs:pattern and xs:enumeration.

However, the semantic of the member datatypes isn’t completely lost for an application built on a PSVI, since the validator needs to perform canonicalization according to the first member type that matches the instance value. This implies that order matters in the list of member types. When both styles are used, the datatypes referenced in the memberTypes are tested before the locally defined datatypes.

Restrictions

None.

Example

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

Attributes

id

W3C ...

Get XML Schema now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.