next up previous contents
Next: While loops Up: Gwendia language Previous: Data links   Contents

Conditionals (if/then/else)

Specific out ports tags (<outThen> and <outElse>) are used in that kind of node. An outThen port will receive data assigned according to the assignment list in the <then> tag only when the condition is evaluated to true. If the condition is false, this port will not receive data but the <outElse> port will receive data according to the assignment list in the <else> tag (assignment lists are semi-column separated lists of assignments of an outThen or outElse port to an input port).
  <condition name="IF_Example">
    <in name="i" type="integer" />
    <in name="j" type="integer" />
    <outThen name="out1" type="integer" />
    <outElse name="out2" type="integer" />
    <!-- IF Condition must be written in XQuery language -->
    <if>$i lt $j</if>
Note that all the operators and functions defined in the XQuery standard (see can be used to make the boolean expression of the <if> tag. These can process both numerical and string variables, and can also contain XPath expressions to access elements of an array when the input port type is an array (e.g., the expression `` contains($inlistitem[1]text(), 'a') '' tests if the 1st element of the array provided by the 'in' port contains the letter 'a').

The DIET Team - Ven 6 jul 2012 11:19:05 CEST