XSLT <xsl:text>Element
Complete XSLT Element Reference
Definition and Usage
The <xsl:text> element is used to write text to the output, i.e., to generate text nodes through the stylesheet.
Tip:This element can contain text, entity references, and #PCDATA.
Syntax
<xsl:text
disable-output-escaping="yes|no">
<!-- Content:#PCDATA -->
</xsl:text>
disable-output-escaping="yes|no">
<!-- Content:#PCDATA -->
</xsl:text>
Attributes
| Attribute | Value | Description |
|---|---|---|
| disable-output-escaping | yes no |
Optional. If the value is "yes", text nodes generated by instantiating the <xsl:text> element will not be escaped during output. For example, "<" will be output as "<". If the value is "no", then "<" will be output as "<". The default is "no". Netscape 6 does not support this attribute. |
Example 1
Display the title of each CD. If it is not the last or second-to-last CD, insert ", " between each cd-title. If it is the last CD, add "!" after the title. If it is the second-to-last CD, add ", and " after the title:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>My CD Collection</h2>
<p>Titles:
<xsl:for-each select="catalog/cd">
<xsl:value-of select="title"/>
<xsl:if test="position() < last()-1">
<xsl:text>, </xsl:text>
</xsl:if>
<xsl:if test="position()=last()-1">
<xsl:text>, and </xsl:text>
</xsl:if>
<xsl:if test="position()=last()">
<xsl:text>!</xsl:text>
</xsl:if>
</xsl:for-each>
</p>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>My CD Collection</h2>
<p>Titles:
<xsl:for-each select="catalog/cd">
<xsl:value-of select="title"/>
<xsl:if test="position() < last()-1">
<xsl:text>, </xsl:text>
</xsl:if>
<xsl:if test="position()=last()-1">
<xsl:text>, and </xsl:text>
</xsl:if>
<xsl:if test="position()=last()">
<xsl:text>!</xsl:text>
</xsl:if>
</xsl:for-each>
</p>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Complete XSLT Element Reference Other Extensions