Conditional value execution
Anatomy
<if value1="string" value2="string|regexp" func="=">
ixml
<elseif value1="string" value2="string|regexp" func="string">ixml</elseif>
<elseis var="var" type="type">ixml</elseis>
<else>ixml</else>
</if>
Description: The IF construct is a control flow structure that allows for conditional execution of code dependent on two values.
If the condition is true, the embedded code is executed. Otherwise, a series of embedded ELSEIF and ELSEIS statements is tested one by one. Only the first ELSEIF or ELSEIS statement that is found to be true will be executed. If none of the conditions are true, the embedded ELSE statement will be executed instead.
Attention:
Comparison of numeric values is always performed numerically regardless of the intrinsic data types.
Regular expression matches regard 'value1' as the subject and 'value2' as the pattern.
IF will propagate results into the context of its paternal statement.
Attributes
| Name | Type | Description | Defined By |
|---|---|---|---|
| value1 | string | Value to compare from | if |
| value2 | string|regexp | Value to compare to | if |
| func | string | Comparison function | if |
Children
elseif
Anatomy of Elsewise conditional value execution
<elseif value1="string" value2="string|regexp" func="string">ixml</elseif>
Attributes:
| Name | Type | Description |
|---|---|---|
| value1 | string | Value to compare from |
| value2 | string | regexp |
| func | string | Comparison function |
elseis
Anatomy of Elsewise conditional type execution
<elseis var="var" type="type">ixml</elseis>
Attributes:
| Name | Type | Description |
|---|---|---|
| var | var | Variable name |
| type | type | Type |
else
Anatomy of Elsewise execution
<else>ixml</else>
Examples
Basic comparison
<set var="name">iXML</set>
<if value1="$name" func="=" value2="iXML">
<output>My name is iXML!</output>
<else>
<output>My name is not iXML!</output>
</else>
</if>
<!-- My name is iXML! -->
Multiple comparison
<set var="name">Steve Jobs</set>
<if value1="$name" func="=" value2="Bill Gates">
<output>My name is Bill Gates!</output>
<elseif value1="$name" func="=" value2="Steve Jobs">
<output>My name is Steve Jobs!</output>
</elseif>
<else>
<output>My name is not Bill Gates nor Steve Jobs!</output>
</else>
</if>
<!-- My name is Steve Jobs! -->
Regular expression match
<set var="name">iXML</set>
<if value1="$name" func="~" value2="/^I/i">
<output>My name starts with an I!</output>
</if>
<!-- My name starts with an I! -->