Generating Text with xsl:text

You can create text nodes with the <xsl:text> element, allowing you to do things such as replace whole elements with text on the fly. One reason you can use <xsl:text> is to preserve whitespace, as in this example from earlier in the chapter, where I used <xsl:text> to insert spaces:to use <xsl:text> is when you want characters such as < and & to appear in your output document, not &lt; and &amp;. To do that, you set the <xsl:text> element's disable-output-escaping

 <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/PLANETS"> <HTML> <HEAD> <TITLE> The Planets Table </TITLE> </HEAD> <BODY> <H1> The Planets Table </H1> <TABLE> <TD>Name</TD> ...

Get Inside XML 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.