Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

XSLT <xsl:text> elements


May 28, 2021 XSL T


Table of contents


XSLT -lt;xsl:text> element

The XSLT-lt;xsl:text-gt; element is used to write a paragraph of text to the output.


XSLT <xsl:text> elements Complete XSLT element reference manual

Definitions and usages

The element is used to write text to the output, i.e. to generate text nodes from style sheets.

Tip: The element can contain text, entity references, and #PCDATA.


Grammar

<xsl:text
disable-output-escaping="yes|no">

<!-- Content:#PCDATA -->

</xsl:text>

Property

Attributes value describe
disable-output-escaping yes
no
可选。如果值为 "yes",通过实例化 <xsl:text> 元素生成的文本节点在输出时将不进行任何转义。比如 "<" 将输出为 "<"。如果值为 "no",则 "<" 将输出为 "<"。默认是 "no"。

Netscape 6 does not support this property.

Instance 1

Displays the title for each CD. I f it is not the last or penultimate CD, insert ", " between each cd-title. I f it's the last CD, add "!" after title. If it's the penultimate CD, add ", and" after 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>

That's the whole story of the element.


XSLT <xsl:text> elements Complete XSLT element reference manual