Table of Contents

XSLT - Whitespace

About

When a newline is not present, whitespace is generally ignored. To include whitespace in the output in such cases, or to include other text, you can use the

<xsl:text>tag.
Articles Related
Removing Whitespace

When you look at the structure of a DOM, there are many text nodes that contain nothing but ignorable whitespace. Most of the excess whitespace in the output comes from these nodes. Fortunately, XSL gives you a way to eliminate them.

To remove some of the excess whitespace, add the strip-space node

<xsl:stylesheet ... >

<xsl:strip-space elements="SECT"/>

[...]

That last little bit of whitespace is disposed of by adding the following to the stylesheet:

<xsl:template match="text()">
 <xsl:value-of select="normalize-space()"/>
</xsl:template>