<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet href="../make-menu.xsl" type="text/xsl"?><html>
   <head>
      <this-is section="expressions" page="for" subpage=""/>
      <!--
           Generated at 2010-10-29T18:20:48.427+01:00--><title>Saxonica: XSLT and XQuery Processing: For Expressions</title>
      <meta name="coverage" content="Worldwide"/>
      <meta name="copyright" content="Copyright Saxonica Ltd"/>
      <meta name="title" content="Saxonica: XSLT and XQuery Processing: For Expressions"/>
      <meta name="robots" content="noindex,nofollow"/>
      <link rel="stylesheet" href="../saxondocs.css" type="text/css"/>
   </head>
   <body class="main">
      <h1>For Expressions</h1>
      <p>The expression <code>for $x in E1 return E2</code> returns the sequence that results from evaluating
<code>E2</code> once for every item in the sequence <code>E1</code>. Note that <code>E2</code> must
use the range variable <code>$x</code> to refer to the item being
tested; it does not become the context item. For example, <code>sum(for $v in order-item return
$v/price * $v/quantity)</code> returns the total value of (price times quantity) for all the
selected <code>order-item</code> elements.</p>
      <table width="100%">
         <tr>
            <td>
               <p align="right"><a class="nav" href="boolean.xml">Next</a></p>
            </td>
         </tr>
      </table>
   </body>
</html>