<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet href="../make-menu.xsl" type="text/xsl"?><html>
   <head>
      <this-is section="xsl-elements" page="value-of" subpage=""/>
      <!--
           Generated at 2011-12-09T20:47:22.916Z--><title>Saxonica: XSLT and XQuery Processing: xsl:value-of</title>
      <meta name="coverage" content="Worldwide"/>
      <meta name="copyright" content="Copyright Saxonica Ltd"/>
      <meta name="title" content="Saxonica: XSLT and XQuery Processing: xsl:value-of"/>
      <meta name="robots" content="noindex,nofollow"/>
      <link rel="stylesheet" href="../saxondocs.css" type="text/css"/>
   </head>
   <body class="main">
      <h1>xsl:value-of</h1>
      <p>The <code>xsl:value-of</code> element evaluates an expression as a string,
 and outputs its value to the current result tree.</p>
      <p>The full syntax of expressions is outlined in <a class="bodylink" href="../expressions/intro.xml">XPath Expression Syntax</a>.
</p>
      <p>The <code>select</code> attribute identifes the expression. If this is not specified, the value
to be output is obtained by evaluating the sequence constructor contained within the <code>xsl:value-of</code>
element.</p>
      <p>The optional <code>disable-output-escaping</code> attribute may be set to "yes" or "no"; the default is
"no". If set to "yes", special characters such as "&lt;" and "&amp;" will be output as themselves,
not as entities. Be aware that in general this can produce non-well-formed XML or HTML. It is useful,
however, when generating things such as ASP or JSP pages. Escaping may not be disabled when writing
to a result tree fragment.</p>
      <p>If the <code>select</code> expression evaluates to a sequence containing more than one item,
the result depends on whether a <code>separator</code> attribute is present. If the
<code>separator</code> is absent when running in 1.0 mode, then only the
first item is considered. When running in 2.0 mode, all the items are output. The separator
defaults to a single space if the <code>select</code> attribute is used, or to a zero-length string
if a sequence constructor is used. The <code>separator</code> attribute may be specified
as an <i>attribute value template</i>.</p>
      <p>Here are some examples of expressions that can be used in the select attribute:</p>
      <table>
         <tr>
            <td content="para">
               <p>
               <b>Expression</b>
            </p>
            </td>
            <td content="para">
               <p>
               <b>value</b>
            </p>
            </td>
         </tr>
         <tr>
            <td content="para">
               <p>TITLE</p>
            </td>
            <td content="para">
               <p>The character content of the first child TITLE element if there is one</p>
            </td>
         </tr>
         <tr>
            <td content="para">
               <p>@NAME</p>
            </td>
            <td content="para">
               <p>The value of the NAME attribute of the current element if there is one</p>
            </td>
         </tr>
         <tr>
            <td content="para">
               <p>.</p>
            </td>
            <td content="para">
               <p>The expanded character content of the current element</p>
            </td>
         </tr>
         <tr>
            <td content="para">
               <p>../TITLE</p>
            </td>
            <td content="para">
               <p>The expanded character content of the first TITLE child of the
    parent element, if there is one</p>
            </td>
         </tr>
         <tr>
            <td content="para">
               <p>ancestor::SECTION/TITLE</p>
            </td>
            <td content="para">
               <p>The expanded character content of the first TITLE child of the
    enclosing SECTION element, if there is one</p>
            </td>
         </tr>
         <tr>
            <td content="para">
               <p>ancestor::*/TITLE</p>
            </td>
            <td content="para">
               <p>The expanded character content of the first TITLE child of the
    nearest enclosing element that has a child element named TITLE</p>
            </td>
         </tr>
         <tr>
            <td content="para">
               <p>PERSON[@ID]</p>
            </td>
            <td content="para">
               <p>The content of the first child PERSON element having an ID attribute,
    if there is one</p>
            </td>
         </tr>
         <tr>
            <td content="para">
               <p>*[last()]/@ID</p>
            </td>
            <td content="para">
               <p>The value of the ID attribute of the last child element of any type,
     if there are any </p>
            </td>
         </tr>
         <tr>
            <td content="para">
               <p>.//TITLE</p>
            </td>
            <td content="para">
               <p>The content of the first descendant TITLE element if there is one</p>
            </td>
         </tr>
         <tr>
            <td content="para">
               <p>sum(*/@SALES)</p>
            </td>
            <td content="para">
               <p>The numeric total of the values of the SALES attributes of all child
    elements that have a SALES attribute</p>
            </td>
         </tr>
      </table>
      <table width="100%">
         <tr>
            <td>
               <p align="right"><a class="nav" href="variable.xml">Next</a></p>
            </td>
         </tr>
      </table>
   </body>
</html>