Conditionals
if — Conditional value execution
The IF command is the primary conditional construct in iXML. It evaluates a comparison and executes its content only if the result is true.
Syntax
XML
<if value1="$a" func="=" value2="$b">
<!-- Executed if a == b -->
</if>
Attributes
| Name | Type | Description |
|---|---|---|
value1 | string | Left operand. |
value2 | string | Right operand. |
func | function | Comparison operator (default =). |
Comparison Operators
func | Description |
|---|---|
= | Equals. |
!= | Not equals. |
> | Greater than. |
< | Less than. |
>= | Greater or equal. |
<= | Less or equal. |
~ | Regex match. |
!~ | Regex non-match. |
is — Conditional type check
The IS command checks the validity, type, or state of a single variable.
Syntax
XML
<is var="myVar" type="numeric">
<!-- Executed if myVar is numeric -->
</is>
Common Types
valid(defined and not null/false)empty(null, false, empty string, empty array)array,string,int,float,boolnumeric
switch — Multi-way branching
Full reference → | case reference → | default reference →
The SWITCH command simplifies chains of if-elseif statements comparing a single value against multiple options.
Syntax
XML
<switch value="$status">
<case value="active">Active!</case>
<case value="pending">Pending...</case>
<default>Unknown status</default>
</switch>