다음을 통해 공유


Effects of White Space in the Style Sheet (Windows Embedded CE 6.0)

1/6/2010

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.

<td> </td>

However, if your style sheet places this sequence of text as-is in the result tree, it will appear as follows.

<td></td>

Not all browsers will display a NULL cell properly.

Use the <xsl:text> element around any white-space-only text nodes.

<td><xsl:text> </xsl:text></td>

For more information, see Controlling White Space with <xsl:text>.

See Also

Concepts

Controlling White Space with XSLT