XML technologies / XML Schema / Data type reference / xs:token
(Excerpt from “XML Schema” by Eric van der Vlist)
Strings with whitespace replacement and collapsing
Derived from: xs:normalizedString
Primitive type: xs:string
Known subtypes: xs:language, xs:NMTOKEN, xs:Name
Facets: xs:enumeration, xs:length, xs:maxLength, xs:minLength, xs:pattern, xs:whiteSpace
Definition
<xs:simpleType name="token" id="token">
<xs:restriction base="xs:normalizedString">
<xs:whiteSpace value="collapse"/>
</xs:restriction>
</xs:simpleType>Description
The lexical and value spaces of xs:token consist of strings after whitespace replacement: each occurrence of #x9 (tab), #xA (line feed) and #xD (carriage return) is replaced by #x20 (space), then whitespace is collapsed: consecutive spaces become one and leading and trailing spaces are removed.
Put simply, xs:token is the most suitable data type for strings where whitespace is insignificant.
Restrictions
The name xs:token is misleading because whitespace is allowed within xs:token . Instead, xs:NMTOKEN corresponds to what is usually called a token.
Example
The element:
<title lang="de">
Auf den
Hund gekommen
</title> is valid for xs:token, and its value is the string “Auf den Hund gekommen”: all whitespace has been replaced by spaces, leading and trailing spaces removed, and consecutive spaces collapsed to one.
Copyright © 2003 O'Reilly Verlag GmbH & Co. KG
You may print the online version for your private use.
Otherwise, this chapter from “XML Schema” is subject to the same conditions as the bound edition. The work, including all its parts, is protected by copyright. All rights reserved, including reproduction, translation, microfilming, and storage and processing in electronic systems.
O’Reilly Verlag GmbH & Co. KG, Balthasarstraße 81, 50670 Köln, kommentar(at)oreilly.de