<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet href="../make-menu.xsl" type="text/xsl"?><html>
   <head>
      <this-is section="expressions" page="range" subpage=""/>
      <!--
           Generated at 2010-10-29T18:20:48.427+01:00--><title>Saxonica: XSLT and XQuery Processing: Range expressions</title>
      <meta name="coverage" content="Worldwide"/>
      <meta name="copyright" content="Copyright Saxonica Ltd"/>
      <meta name="title" content="Saxonica: XSLT and XQuery Processing: Range expressions"/>
      <meta name="robots" content="noindex,nofollow"/>
      <link rel="stylesheet" href="../saxondocs.css" type="text/css"/>
   </head>
   <body class="main">
      <h1>Range expressions</h1>
      <p>The expression <code>E1 to E2</code> returns a sequence of integers. For example, <code>1 to 5</code>
returns the sequence <code>1, 2, 3, 4, 5</code>. This is useful in <code>for</code> expressions, for example
the first five nodes of a node sequence can be processed by writing <code>for $i in 1 to 5 return (//x)[$i]</code>.</p>
      <p>If you prefer, you can write this as <code>(//x)[position() = 1 to 5]</code>. This works because
comparison of a single integer (<code>position()</code>) to a sequence of integers (<code>1 to 5</code>)
is true if the integer on the left is equal to any integer in the sequence.</p>
      <table width="100%">
         <tr>
            <td>
               <p align="right"><a class="nav" href="comparisons.xml">Next</a></p>
            </td>
         </tr>
      </table>
   </body>
</html>