By declaring a , you can validate the values in your instance document against multiple types. : union « XML Schema « XML Tutorial






<union memberTypes="whitespace separated list of types"> 

You specify the types you are combining by including the memberTypes attribute. 
The value of the memberTypes attribute should be a whitespace-separated list of references to global <simpleType> definitions or built-in XML Schema datatypes. 
The <union> declaration also allows you to specify your memberTypes by creating local <simpleType> definitions. 

<simpleType name="UnknownString"
  <restriction base="string"
    <enumeration value="Unknown" />
    </restriction>
</simpleType>


<simpleType name="UnknownOrFloatType"
    <union memberTypes="float contacts:UnknownString"/>
</simpleType>

<element name="latitude" type="contacts:UnknownStringOrFloatType"/> 
<element name="longitude" type="contacts:UnknownStringOrFloatType"/> 

Some valid elements include the following: 

<latitude>43.847156</latitude> 
<longitude>Unknown</longitude> 

Some invalid elements include these: 

<latitude>unknown</latitude> 
<longitude>43.847156 Unknown</longitude>








3.80.union
3.80.1.By declaring a , you can validate the values in your instance document against multiple types.
3.80.2.The union method joins the value spaces and lexical spaces of one or more datatypes to derive a new type
3.80.3.When the values of a union datatype are validated, they’re validated in the order in which they’re defined