Latest web development tutorials

XSLT <xsl: text> element

XSLT Elements Reference Manual Complete XSLT Element Reference Manual

Definition and Usage

<Xsl: text> element is used to write text output, which generates a text node through style sheets.

Note: This element can contain text, entity references, as well as #PCDATA.


grammar

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

<!-- Content:#PCDATA -->

</xsl:text>

Attributes

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

Netscape 6 不支持该属性。

Example 1

Display of each CD title. If it is not the last or penultimate CD, then in between each cd-title insert "." If it is the last CD, then add in the title! "." If this is the penultimate CD, then after the title add ", and":

<?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>


XSLT Elements Reference Manual Complete XSLT Element Reference Manual