XML technologies / XML Schema / Data type reference / xs:normalizedString

(Excerpt from “XML Schema” by Eric van der Vlist)

Strings with replaced whitespace

Derived from: xs:string

Primitive type: xs:string

Known subtypes: xs:token

Facets: xs:enumeration, xs:length, xs:maxLength, xs:minLength, xs:pattern, xs:whiteSpace

Definition

<xs:simpleType name="normalizedString" id="normalizedString">
  <xs:restriction base="xs:string">
    <xs:whiteSpace value="replace"/>
  </xs:restriction>
</xs:simpleType>

Description

The lexical space of xs:normalizedString is unrestricted: any valid XML character may be used. Its value space consists of strings after whitespace replacement, replacing each #x9 (tab), #xA (line feed) and #xD (carriage return) with #x20 (space), without collapsing whitespace.

Restrictions

This is the only data type replacing whitespace without collapsing it. If whitespace is insignificant, xs:token is preferred.

This data type corresponds neither to the XPath function normalize-space( ), which trims leading and trailing whitespace and collapses the rest, nor to the DOM method normalize, which merges adjacent text objects.

Example

The value of element

<title lang="de">
    Auf den
    Hund gekommen
</title>"

is the string "Auf den Hund gekommen". All whitespace has been replaced by spaces if the title element has type xs:normalizedString.

   

 

 

 

back to top