Use these functions to perform conditional and block processing within expressions.
Groups more than one expression into a single expression. The value of the block function is the value of its last argument.
The <set> function does not return a value. If the last line in a block statement involves a set operation, the block statement will not return a value. If you want the block statement to return the value of a variable, use <ref>variable_name</ref> on the last line of the block statement.
<block> <s>Hello there!</s> <add> <i>100</i> <i>2</i> </add> <i>42</i> </block>
The block returns a value of 42, the value of its last argument.
For an example of using block with a trace statement, see Debugging and Testing Expressions.
Forces early termination of an expression. A break can be used within the following expressions: block, dolist, while, and, or. The value of the break expression becomes the value of the containing expression. The break can cause the termination of several levels of expression when the optional block name is used.
The following expression contains a simple break terminating a loop.
<dolist name=’el’> <ref>list</ref> <cond><eq><ref>el</ref><s>000</s></eq> <break> <ref>el</ref> </break> </cond> <null/> </dolist>
In this example, the dolist function iterates over the elements of a list looking for value 000. The value of the dolist function is a list formed by concatenating the values that are returned by the last subexpression in each iteration.
The following expression demonstrates the use of a block name to break through more than one level.
<block name=’outer block’> <dolist name=’el’> <ref>listOfLists</ref> <dolist name=’el2’> <ref>el</ref> <cond><eq><ref>el</ref><s>000</s></eq> <break name=’outer block’> <ref>el</ref> </break> </cond> </dolist> <null/> </dolist> </block>
This is similar to the previous example except that there are two loops. The outer loop iterates over a list whose elements are themselves lists. The inner loop iterates over the element lists. When the value 000 is found, both loops are terminated by referencing the block name outer block in the break expression.
Provides a way to conditionally select the value of one of two expressions. It is similar to the ternary conditional operator (a?b:c) in C and Java.
The cond function allows three arguments. The first argument is called the condition. If the value of the condition is logically true, the value of the cond will be the value of the second argument. If the value of the condition is false, the value of the cond will be the value of the third argument. If the value of the condition is false, and the third argument not present, the value of the cond is null.
<cond> <gt> <ref>age</ref> <i>40</i> </gt> <s>old</s> <s>young</s> </cond>
Iterates over the elements of a list. The value of the name attribute will become the name of variable that can be referenced within the loop.
The value of this variable will be the value of successive list elements.
The first subexpression returns the list over which to loop. The remaining subexpressions are repeated once for each element in the list.
The value of the dolist function is a list formed by concatenating the values returned by the last subexpression in each iteration.
The following expression creates a list called subset, which contains the subset of elements in srclist that exceed 10.
<set name=’subset’> <dolist name=’el’> <cond> <gt> <ref>el</ref> <i>10</i> </gt> <ref>el</ref> </cond> </dolist> </set>
first argument - any XPRESS expression
second arguments - series of <case> elements
The first argument is evaluated and compared against each of the <case> elements until a match is found. The <switch> function evaluates to the first <case> for which there is a match. If no match is found, the <switch> evaluates to the <case> element where default=’true’.
The following expression returns apples.
<switch> <s>A</s> <case default=’true’> <s>unknown</s> </case> <case> <s>A</s> <s>apples</s> </case> <case> <s>B</s> <s>oranges</s> </case> </switch>
Returns the first non-null (and non-zero) value in a list.
<select> <ref>:display.session</ref> <ref>context</ref> </select>
If you have the following statement:
<select> <ref>first/ref> <ref>second</ref> <ref>third</ref. </select>
This statement would first check to see if first was null. If not, it would return the value of first, or move on to the next item until one returns true or all items are exhausted.
You can use this function when you need to obtain the correct context from, for example, a workflow or when calling a formUtil method.
Using select in this way allows you to call formUtil methods from anywhere in Waveset without knowing which variable houses the Lighthouse Context. In a form, you would specify the context with <ref>:display.session</ref>. However, for the same FormUtil call in a Workflow, you must instead use <ref>context</ref>.
Repeats a set of expressions until a condition is met. The first subexpression is called the conditional and will be evaluated each time through the loop. The loop terminates when the conditional is logically false. The value of the while expression is the value of the last expression in the loop during the last iteration.
The following expression returns null.
<while> <gt> <ref>counter</ref> <i>0</i> </gt> <set name=’counter’> <sub> <ref>counter</ref> <i>1</i> </sub> </set> </while>