Xvcl Pages; [ Cjos Audience]
Article contributed by Gilbert Herschberger (6 October 2005).
Overview
The while tag works with a variable with multiple values.
Setting a variable
To set a variable with multiple values, use the set-multi tag.
<set-multi var="n" value="v"/>
Getting a variable
To get the value of a variable, use the value-of tag.
<value-of expr="?@n?"/>
Looping
To use a variable with multiple values, use the while tag.
<while using-items-in="n"/>
Colors
In the following example, a variable called color is list of colors. A list of colors is emitted.
<set-multi var="color" value="red,yellow,pink,green"/>
<while using-items-in="color">
<value-of expr="?@color?"/>
</while>
Output:
red
yellow
pink
green
Coordinates
In the following example, x,y,z is a coordinate.
<set-multi var="x" value="1,2,3"/>
<set-multi var="y" value="4,5,6"/>
<set-multi var="z" value="7,8,9"/>
<while using-items-in="x,y,z">
<value-of expr="?@x?,?@y?,?@z?"/>
</while>
Output:
1,4,7
2,5,8
3,6,9
Matrix
In the following example, row-column is a matrix.
<set-multi var="row" value="a,b"/>
<set-multi var="column" value="1,2,3"/>
<while using-items-in="row">
<while using-items-in="column">
<value-of expr="?@row?-?@column?"/>
</while>
</while>
Output:
a-1
a-2
a-3
b-1
b-2
b-3
Contents
This document contains the following sections.
Section A - Notes
Introduction
This section contains notes on the use of the while construct.
Notes
One part of the source code contains a repeating pattern.
- How do I use a while construct?
Sample
<set-multi var="n" value="1,2,3"/>
<while using-items-in="n">
</while>
|