Controlling White Space with XSLT (Windows Embedded CE 6.0)
1/6/2010
Any Extensible Markup Language (XML) document exercises some control over white space. The parser handles white space in an XML document according to the xml:space attribute and default white space rules before the document is even accessed by the XSL Transformations (XSLT) processor.
The XML 1.0 specification imposes the following white space rules.
Because different operating systems represent line breaks in different ways, as true newlines, carriage returns, linefeed-carriage return character pairs, and so on, any newline characters specific to an operating system are normalized by the parser to a true newline (hex x0A, or decimal 10).
The values of attributes, other than CDATA-type attributes, are normalized by replacing multiple consecutive occurrences of white space with a single space. For example, an attribute value such as "text text" with four intervening spaces embedded in the attribute value is passed from the parser as "text text"; the multiple spaces in the original value are replaced with a single space.
Note
If an xml:space attribute in the source XML document or style sheet conflicts with explicit XSLT white space handling, the behavior associated with that xml:space attribute always takes precedence.
According to the XSLT specification, the XSLT processor merges adjacent text nodes into a single text node. This release of the Microsoft® XSLT processor does not implement this functionality. If a text node, following any merging that occurs, consists of white space only, the containing element is compared to the list of elements in any <xsl:strip-space> elements in the style sheet. If the containing element appears in such a list, the white-space-only text node is removed from the result tree.
This applies only to insignificant white space, that is, white space between, not within, elements. Use the XSLT normalize-space() function to normalize white space within elements.
Note
White space is handled by the Microsoft® XML Parser (MSXML) for Windows Embedded CE as a whole by its built-in parser as well as its built-in XSLT processor. For more information, see Handling White Space.
See Also
Concepts
Exploring XSLT Capabilities
What is White Space?
Handling White Space
Controlling White Space with <xsl:text>
Preserving and Stripping White Space
<xsl:preserve-space> and <xsl:strip-space> Example
Overriding <xsl:preserve-space> and <xsl:strip-space>
Creating CDATA Sections
Using the Normalize-space() Function
Controlling White Space with the DOM
preserveWhiteSpace Property and HTML
Effects of White Space in the Style Sheet
Release Notes: Handling White Space with the MSXML Processor