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 thehtmlorxmloutput methods. If you use<xsl:output method="test">, the attribute is ignored becasue output escaping is not done for thetextoutput method. See <xsl:text> for a more thorough discussion of thedisable-output-escapingattribute.
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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access