Defines a collection of multiple simpleType definitions.
<union id = ID memberTypes = List of QNames {any attributes with non-schema Namespace}…> Content: (annotation?, (simpleType*)) </union>
Optional.
For simple type union definitions, the list of simple types is the union of the contents of memberTypes (which is itself a list of simple types) and each of the child simpleType element definitions under the union element. See the second example later in this topic.
The memberTypes attribute is opposite of the itemType attribute for the list element which is mutually exclusive to the simpleType element child of the list element.
Optional.
Number of occurrences | One time |
Parent elements | simpleType |
Contents | annotation, simpleType |
The following example shows a simple type that is a union of two simple types.
<xs:attribute name="fontsize"> <xs:simpleType> <xs:union memberTypes="fontbynumber fontbystringname" /> </xs:simpleType> </xs:attribute> <xs:simpleType name="fontbynumber"> <xs:restriction base="xs:positiveInteger"> <xs:maxInclusive value="72"/> </xs:restriction> </xs:simpleType> <xs:simpleType name="fontbystringname"> <xs:restriction base="xs:string"> <xs:enumeration value="small"/> <xs:enumeration value="medium"/> <xs:enumeration value="large"/> </xs:restriction> </xs:simpleType>
The following example shows a simple type definition that is a union of all nonnegative integers and the NMTOKEN "unbounded". (This is from the schema in the W3C XML Schema Part 1: Structures specification.)
<xs:simpleType name="allNNI"> <xs:annotation> <xs:documentation>for maxOccurs</xs:documentation> </xs:annotation> <xs:union memberTypes="nonNegativeInteger"> <xs:simpleType> <xs:restriction base="xs:NMTOKEN"> <xs:enumeration value="unbounded"/> </xs:restriction> </xs:simpleType> </xs:union> </xs:simpleType>
XML Schema Reference (XSD) | XML Schema Elements
For more information, see the W3C XML Schema Part 2: Datatypes Recommendation at http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/#derivation-by-union.
World Wide Web Consortium (W3C) XML Schema Part 1: Structures