XML technologies / XML Schema / Using predefined simple data types / Whitespace processing
(Excerpt from “XML Schema” by Eric van der Vlist)
The treatment of certain characters, tab, line feed, carriage return and space, often used to make XML documents look nice, has always been controversial. W3C XML Schema requires a general two-step algorithm applying to most predefined data types, in fact all except two, xs:string and xs:normalizedString.
Whitespace replacement (normalization)
This first processing step applies to the parsed value. Every whitespace occurrence, #x9 (tab), #xA (line feed) and #xD (carriage return), is replaced with a space (#x20), a normalization. The character count is unchanged by this step, applied to all predefined types except xs:string, whose parsed value undergoes no whitespace replacement.
Whitespace collapsing
The second step removes leading and trailing spaces and replaces every uninterrupted run of spaces with one space. It applies to all predefined types except xs:string, whose parsed value undergoes no whitespace replacement, and xs:normalizedString, whose whitespace is only normalized.
This meaning of “normalized string” does not match the XPath function normalize-space(), which corresponds to what W3C XML Schema calls whitespace collapsing. The DOM method normalize() means something else again: merging adjacent text objects.
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