Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

 
 

while

Syntax

Description

Repeatedly execute a block of statements until the specified condition evaluates to false.

The condition is an XPath expression that is converted to a Boolean type. If the expression evaluates to true, the contents of the while loop are executed. The loop continues to execute until the expression evaluates to false. During execution, the context does not change. In the expression, you should use a mutable variable to avoid creating an infinite loop. You declare mutable variables using the mvar statement.

Attributes

expression

XPath expression, which is cast to boolean type and used as the condition for the while loop. The code block contents are executed as long as the condition evaluates to true.

Starting in SLAX version 1.3, the parentheses enclosing the statement expression are optional.

SLAX Example

In the example, the while loop parses through the item list until the required value is found. When the loop detects that value, $seen is set to true, and the while loop exits.

Release Information

Statement introduced in SLAX version 1.1.

Support for syntax with optional parentheses added in SLAX version 1.3.