Defining Atomic Datatypes That Allow Whitespace
It is possible to define lists of atomic datatypes that allow
whitespaces such as xs:string. In this case, whitespaces are
always considered separators.
The impact of this statement can be seen when we apply a facet
constraining the length of such a datatype:
<xs:simpleType name="myStringList">
<xs:list itemType="xs:string"/>
</xs:simpleType>
<xs:simpleType name="myRestrictedStringList">
<xs:restriction base="myStringList">
<xs:maxLength value="10"/>
</xs:restriction>
</xs:simpleType>
The datatype myRestrictedStringList is a list of a
maximum of 10 items. Since these items are separated by whitespaces,
myRestrictedStringList is a list of a maximum of
10 portions of strings that do not contain whitespace (i.e., 10
"words").
This datatype, therefore, validates a value such as:
<myRestrictedStringList>
This value has less than ten words.
</myRestrictedStringList>
But not this one:
<myRestrictedStringList>
This value has more than ten words... even if they could be
spreading less than ten "strings."
</myRestrictedStringList>
Defining lists of lists is forbidden per the W3C XML Schema
Recommendation.
|