Overriding <xsl:preserve-space> and <xsl:strip-space>
Use the xml:space
attribute to override the effect of <xsl:strip-space>
or <xsl:preserve-space>
.
For an example of this, consider strippreserve.xsl in Example of <xsl:preserve-space> and <xsl:strip-space>. Even though the <block>
elements in this file were specified in the <xsl:strip-space>
element list, you could force the preservation of four spaces by including the following in that template rule.
<block><xsl:text xml:space="yes"> </xsl:text></block>
This example is artificial in that it forces the insertion of white space within the style sheet. It does not restore or preserve white space in the original document. To do that, you must override the default stripping of extraneous white space by setting the preserveWhiteSpace
property to True at the time the document is loaded into the Document Object Model (DOM).
See Also
Preserving or Stripping White Space | How the MSXML Processor Parses White Space | White Space and the DOM