<?xml version="1.0" encoding="iso-8859-1"?> <?xml-stylesheet href="../../make-menu.xsl" type="text/xsl"?><html> <head> <this-is section="extensions" page="instructions" subpage="while"/> <!-- Generated at 2011-12-09T20:47:22.916Z--><title>Saxonica: XSLT and XQuery Processing: saxon:while</title> <meta name="coverage" content="Worldwide"/> <meta name="copyright" content="Copyright Saxonica Ltd"/> <meta name="title" content="Saxonica: XSLT and XQuery Processing: saxon:while"/> <meta name="robots" content="noindex,nofollow"/> <link rel="stylesheet" href="../../saxondocs.css" type="text/css"/> </head> <body class="main"> <h1>saxon:while</h1> <p>The <code>saxon:while</code> element is used to iterate while some condition is true.</p> <p>The condition is given as a boolean expression in the mandatory test attribute. Because this expression must change its value if the loop is to terminate, the condition will generally reference a variable that is updated somewhere in the loop using an <code>saxon:assign</code> element. Alternatively, it may test a condition that is changed by means of a call on an extension function that has side-effects. </p> <p>Example:</p> <div class="codeblock" style="border: solid thin; background-color: #B1CCC7; padding: 2px"> <pre> <code> <xsl:variable name="i" select="0" saxon:assignable="yes"/> <xsl:template name="loop"> <saxon:while test="$i &lt; 10"> The value of i is <xsl:value-of select="$i"/> <saxon:assign name="i" select="$i+1"/> </saxon:while> </xsl:template> </code> </pre> </div> <table width="100%"> <tr> <td> <p align="right"/> </td> </tr> </table> </body> </html>