Name
<xsl:value-of> — Calculates the value of an XPath expression, converts that value to a string, and then writes the value to the result tree.
Category
Instruction
Required Attributes
- select
The XPath expression that is evaluated and written to the output document.
Optional Attributes
- disable-output-escaping
An attribute that defines whether special characters are escaped when written to the output document. For example, if the literal text contains the character
>
, it is normally written to the output document as>
. If you codedisable-output-escaping="yes"
, the character>
is written instead. The XSLT processor uses this attribute only if you use thehtml
orxml
output methods. If you use<xsl:output method="test">
, the attribute is ignored becasue output escaping is not done for thetext
output method. See <xsl:text> for a more thorough discussion of thedisable-output-escaping
attribute.
Content
None. <xsl:value-of>
is an empty element.
Appears in
<xsl:value-of>
appears inside a template.
Defined in
XSLT section 7.6.1, Generating Text with xsl:value-of
.
Example
We’ll use the <xsl:value-of>
element to generate some text. Here is our stylesheet:
<?xsl version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text"/> <xsl:variable name="newline"> <xsl:text> </xsl:text> </xsl:variable> <xsl:template match="/"> <xsl:text>Your document contains</xsl:text> <xsl:value-of select="count(//*)"/> <xsl:text> elements and </xsl:text> <xsl:value-of ...
Get XSLT 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.