<html>
<head>
<title>&lt;xsl:value-of&gt;</title>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div id="Description">
<table cellpadding="0" cellspacing="0" border="0" width="100%" class="main">
<tr>
<td valign="top" class="NAME">&lt;xsl:value-of&gt;</td>
<td valign="top" class="COMPATIBILITY">&nbsp;</td>
</tr>
<tr>
<td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
</tr>
<tr>
<td valign="top" colspan="2" class="description">
Calculates the value of an XPath expression, converts that value to a string, and then writes the value to the result tree.</td></tr>
<tr>
<td colspan="2" class="CLEARSEPARATION">&nbsp;</td>
</tr>
<tr>
<td colspan="2" class="TITLE">Category</td>
</tr>
<tr>
<td colspan="2" class="description">
<p>Instruction</p>
</td>
</tr>
<tr>
<td colspan="2" class="CLEARSEPARATION">&nbsp;</td>
</tr>
<tr>
<td colspan="2" class="TITLE">Required Attributes</td>
</tr>
<tr>
<td colspan="2" class="description">
<dl>
<dt>
select
</dt>
<dd>
The XPath expression that is evaluated and written to the output document.
<P></p>
</dl>
</td>
</tr>
<tr>
<td colspan="2" class="CLEARSEPARATION">&nbsp;</td>
</tr>
<tr>
<td colspan="2" class="TITLE">Optional Attributes</td>
</tr>
<tr>
<td colspan="2" class="description">
<dl>
<dt>
disable-output-escaping
</dt>
<dd>
An attribute that defines whether special characters are escaped when written to the output document. For example, if the literal text contains the character
<span class="LITERAL">
&gt;
</span>
, it is normally written to the output document as
<span class="LITERAL">
&amp;
gt;
</span>
. If you code
<span class="LITERAL">
disable-output-escaping=
"
yes
"
</span>
, the character
<span class="LITERAL">
&gt;
</span>
is written instead. The XSLT processor uses this attribute only if you use the
<span class="LITERAL">
html
</span>
or
<span class="LITERAL">
xml
</span>
output methods. If you use
<span class="LITERAL">
&lt;
xsl:output method=
"
test
"
&gt;
</span>
, the attribute is ignored becasue output escaping is not done for the
<span class="LITERAL">
text
</span>
output method. See
<xref linkend="text-element">
&lt;
xsl:text
&gt;
</xref>
for a more thorough discussion of the
<span class="LITERAL">
disable-output-escaping
</span>
attribute.
<P></p>
</dl>
</td>
</tr>
<tr>
<td colspan="2" class="CLEARSEPARATION">&nbsp;</td>
</tr>
<tr>
<td colspan="2" class="TITLE">Content</td>
</tr>
<tr>
<td colspan="2" class="description">
<p>None. <span class="LITERAL">&lt;xsl:value-of&gt;</span> is an empty element.</p>
</td>
</tr>
<tr>
<td colspan="2" class="CLEARSEPARATION">&nbsp;</td>
</tr>
<tr>
<td colspan="2" class="TITLE">Appears in</td>
</tr>
<tr>
<td colspan="2" class="description">
<p><span class="LITERAL">&lt;xsl:value-of&gt;</span> appears inside a template.</p>
</td>
</tr>
<tr>
<td colspan="2" class="CLEARSEPARATION">&nbsp;</td>
</tr>
<tr>
<td colspan="2" class="TITLE">Defined in</td>
</tr>
<tr>
<td colspan="2" class="description">
<p>XSLT section 7.6.1, Generating Text with <span class="LITERAL">xsl:value-of</span>.</p>
</td>
</tr>
<tr>
<td colspan="2" class="CLEARSEPARATION">&nbsp;</td>
</tr>
<tr>
<td colspan="2" class="TITLE">Example</td>
</tr>
<tr>
<td colspan="2" class="description">
<p>We'll use the <span class="LITERAL">&lt;xsl:value-of&gt;</span> element to generate some text. Here is our stylesheet:</p>
<span class="PROGRAMLISTING"><pre>
&lt;?xsl version="1.0"?&gt;
&lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;

  &lt;xsl:output method="text"/&gt;

  &lt;xsl:variable name="newline"&gt;
&lt;xsl:text&gt;
&lt;/xsl:text&gt;
  &lt;/xsl:variable&gt;

  &lt;xsl:template match="/"&gt;
    &lt;xsl:text&gt;Your document contains&lt;/xsl:text&gt;
    &lt;xsl:value-of select="count(//*)"/&gt;
    &lt;xsl:text&gt; elements and &lt;/xsl:text&gt;
    &lt;xsl:value-of select="count(//@*)"/&gt;
    &lt;xsl:text&gt; attributes.  &lt;/xsl:text&gt;
    &lt;xsl:value-of select="$newline"/&gt;
    &lt;xsl:text&gt;Have a great day!&lt;/xsl:text&gt;
  &lt;/xsl:template&gt;
&lt;/xsl:stylesheet&gt;</pre></span>

<p>We'll use this XML document as input:</p>

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

<p>Here are the results:</p>
<span class="PROGRAMLISTING"><pre>
Your document contains 14 elements and 4 attributes.
Have a great day!</pre></span>
</td>
</tr>
</table>
</div>
</body>
</html>