<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 & gt; . If you code disable-output-escaping= " yes " , the character > is written instead. The XSLT processor uses this attribute only if you use the html or xml output methods. If you use < xsl:output method= " test " > , the attribute is ignored becasue output escaping is not done for the text output method. See < xsl:text > for a more thorough discussion of the disable-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 select="count(//@*)"/>
    <xsl:text> attributes.  </xsl:text>
    <xsl:value-of select="$newline"/>
    <xsl:text>Have a great day!</xsl:text>
  </xsl:template>
</xsl:stylesheet>

We'll use this XML document as input:

<?xml version="1.0"?>
<report>
  <title>Miles Flown in 2001</title>
  <month sequence="01">
    <miles-flown>12379</miles-flown>
    <miles-earned>35215</miles-earned>
  </month>
  <month sequence="02">
    <miles-flown>32857</miles-flown>
    <miles-earned>92731</miles-earned>
  </month>
  <month sequence="03">
    <miles-flown>19920</miles-flown>
    <miles-earned>76725</miles-earned>
  </month>
  <month sequence="04">
    <miles-flown>18903</miles-flown>
    <miles-earned>31781</miles-earned>
  </month>
</report>

Here are the results:

Your document contains 14 elements and 4 attributes.
Have a great day!