SAXONICA

Saxon Documentation
Full Contents
About Saxon
Changes in this Release
Conditions of Use
Using XSLT 2.0
Using XQuery
Handling Source Documents
XML Schema Processing
XPath API for Java
Saxon on .NET
Extensibility
Saxon Extensions
| Introduction
| EXSLT Extensions
| Extension attributes (XSLT only)
| Additional serialization parameters
| Extension functions
» | Extension instructions
Sample Saxon Applications
The Saxon SQL Extension
XSLT Elements
XPath 2.0 Expression Syntax
Function Library
Standards Conformance

# saxon:while

The `saxon:while` element is used to iterate while some condition is true.

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 `saxon:assign` element. Alternatively, it may test a condition that is changed by means of a call on an extension function that has side-effects.

Example:

    <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>