Mark Wilson I am the creator of TopXML. I am available for international and local (Australia) contracts. I am a Solution Architect/Business Analyst. I have worked in IT in several countries (NZ, Australia, South Africa, UK) building and training teams for government and very large non-governmental organizations. I am ex-Microsoft Consulting Services. I wrote the first book on Microsoft XML published in 2000 called XML Programming with VB and ASP. Most recently I have been building tools for the SEO industry. Ask me for a 37 point SEO health-checkup for your website.
Whitespace stripping is one of the more confusing subjects in XSLT programming.
What is important to understand is at which moments whitespace can be inserted or removed.
The process of creating a result document from a source document and a stylesheet document has three of these moments:
Creating a tree structure in memory from the source document (some whitespace can get stripped)
Creating a tree structure in memory from the stylesheet document (normally most whitespace is stripped)
Creating a result document from the resulting tree structure in memory (some whitespace can be inserted)
The only whitespace that gets stripped are text nodes existing entirely
of whitespace characters (space, tab, newline).
If one non-whitespace character is included in the textnode, it will
never be stripped.
In step 1, by default no whitespace is stripped. In step 2, all whitespace is
stripped by default, except from xsl:text elements. In step 3, by default no whitespace is added.
To have whitespace stripped from the source document, you can place an
xml:space="preserve" attribute in the source document. It will cause
the descending whitespace nodes to be stripped. In the stylesheet, the xsl:strip-space and
xsl:preserve-space top-level elements can be used to have certain whitespace nodes from the source
document stripped or preserved.
The insertion of whitespace into the XML output document after building the result tree only
happens when the xsl:output top-level element has its indent attribute set to yes. There is no way to
specify whitespace insertion more exactly.
Note: You can now download the full content of the XPath reference, the XSLT reference and the
DOM reference in one PDF document. This document contains the implementation tables, internal
links to navigate through the references, a full linked table of contents. You can use free text
search through the whole reference or print as a nicely formatted document.
Download here...