XSLT <xsl:preserve-space>
and <xsl:strip-space>
Elements
Definition and Usage
The <xsl:preserve-space>
element is used to define elements that should preserve whitespace.
The <xsl:strip-space>
element is used to define elements that should have whitespace removed.
Note: Preserving whitespace is the default setting, so the <xsl:preserve-space>
element is only necessary when the <xsl:strip-space>
element is used.
Note: Both <xsl:preserve-space>
and <xsl:strip-space>
elements are top-level elements.
Syntax
Attributes
Attribute | Value | Description |
---|---|---|
elements | list-of-element-names | Required. A space-separated list of elements that specifies which elements should preserve/remove whitespace. Note: The list can include "" and "prefix:", allowing all elements or all elements from a specific namespace to be included. |
Example 1
In this example, we preserve whitespace nodes for the title and artist elements, and remove whitespace nodes from the country, company, price, and year elements: