5.4.1. Beware of the Order
The order of the different derivation
methods (restriction, list, or union) is significant.
We have already seen that derivation by list and union lose the
semantic meaning of the types and their facets, which are replaced by
a common set of facets with their own meaning (xs:length, xs:maxLength, xs:minLength, xs:enumeration, and xs:whiteSpace for derivation by list, and
xs:pattern and xs:enumeration for derivation by union).
This means that all the restrictions on the atomic or member types
must be done before the derivation by list or members (as we have
seen in the corresponding sections for the facets) and that a new
restriction can then be performed using the common set of facets.
The order between derivation by list and derivation by union depends
on the result to achieve, as a list of unions is different from a
union of lists, as one might expect:
<xs:simpleType name="listOfUnions">
<xs:list>
<xs:simpleType>
<xs:union memberTypes="xs:date xs:integer"/>
</xs:simpleType>
</xs:list>
</xs:simpleType>
<xs:simpleType name="UnionOfLists">
<xs:union>
<xs:simpleType>
<xs:list itemType="xs:date"/>
</xs:simpleType>
<xs:simpleType>
<xs:list itemType="xs:integer"/>
</xs:simpleType>
</xs:union>
</xs:simpleType>
These two datatypes match the following:
<UnionOfLists>
2001-01-01 2001-01-02
</UnionOfLists>
<UnionOfLists>
1 2 3
</UnionOfLists>
<ListOfUnions>
2001-01-01 2001-01-02
</ListOfUnions>
<ListOfUnions>
1 2 3
</ListOfUnions>
<ListOfUnions>
2001-01-01 1 2
</ListOfUnions>
But don't match:
<UnionOfLists>
2001-01-01 1 2
</UnionOfLists>
This requires all the items of the list to have the same member type.
The order in which a set of derivation by restriction is completed is
also significant when the same facets are being redefined, since we
have seen that there are some restrictions that depend on the facets
being used.