Important: |
---|
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist. |
White-space-only nodes in the XSLT style sheet are stripped by the XSLT processor, as opposed to those in the source document, which are stripped by the DOM processor.
It can be an advantage to have extraneous white space stripped from a style sheet. You can format the style sheet for easy readability and maintenance, knowing that extra tabs, newlines, and so on will not appear in the result tree.
However, this can be a disadvantage in those cases in which you need white space of a particular kind in the result tree. For example, if you had to insert a blank space in a table cell, you might expect the following.
Copy Code | |
---|---|
<td> </td> |
However, if your style sheet places this sequence of text as-is in the result tree, it will appear as follows.
Copy Code | |
---|---|
<td></td> |
Not all browsers will display a NULL cell properly.
Use the <xsl:text> element around any white-space-only text nodes.
Copy Code | |
---|---|
<td><xsl:text> </xsl:text></td> |
For more information, see Controlling White Space with <xsl:text>.