The <xsl:strip-space> and <xsl:preserve-space> Elements

The <xsl:stripspace> element causes the XSLT processor to strip all pure whitespace nodes (also called “expendable” whitespace nodes) from the input document. A pure whitespace node consists of only whitespace characters, without any other type of text. This element has only one attribute:

  • elements (mandatory). Specifies the elements from which to strip the whitespace. Set to a whitespace-separated list of NameTests (which are names or generic names with wildcards).

This element contains no content.

For example, to strip all whitespace nodes from planets.xml, I could use <xsl:strip-space elements="*"/> like this:

 <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> ...

Get Inside XSLT now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.