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), e.g.,:
  <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>
    <then>out1=i;</then>
    <else>out2=j;</else>
  </condition>
Note that all the operators and functions defined in the XQuery standard (see http://www.w3.org/TR/xquery-operators/) 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($in/list/item[1]/text(), 'a') ” tests if the 1st element of the array provided by the 'in' port contains the letter 'a').



The DIET Team - Mer 29 nov 2017 15:13:36 EST