by Eric van der Vlist is published by O'Reilly & Associates (ISBN: 0596004214)


Name

xsd:token — Whitespace-replaced and collapsed strings

Synopsis

<xsd:simpleType name="token" id="token">
 <xsd:restriction base="xsd:normalizedString">
 <xsd:whiteSpace value="collapse"/>
 </xsd:restriction>
</xsd:simpleType>

Derived from

xsd:normalizedString

Primary

xsd:string

Known subtypes

xsd:language, xsd:NMTOKEN, xsd:Name

Data parameters (facets)

enumeration, length, maxLength, minLength, pattern

Description

The lexical and value spaces of xsd:token are the sets of all strings after whitespace replacement; i.e., after any occurrence of #x9 (tab), #xA (linefeed), or #xD (carriage return).These are replaced by an occurrence of #x20 (space) and collapsing. Collapsing is when contiguous occurrences of spaces are replaced by a single space, and leading and trailing spaces are removed.

More simply, xsd:token is the most appropriate datatype to use for strings that don't care about whitespace.

Restrictions

The name xsd:token is misleading, as whitespace is allowed within xsd:token. xsd:NMTOKEN is the type corresponding to what are usually called tokens.

Example

The element:

<title lang="en">
  Being a Dog Is 
  a Full-Time Job
</title>

is a valid xsd:token, and its value is the string Being a Dog Is a Full-Time Job, in which all the extra whitespace has been replaced by single spaces. Leading and trailing spaces have been removed, and contiguous sequences of spaces have been replaced by single spaces.


This text is released under the Free Software Foundation GFDL.