Skip to content

Element <else-if>

Purpose: Evaluate a fallback condition after earlier branches did not match.

Why: Use it for a later conditional branch after previous branches did not match.

Example

1
<else-if condition="customer.is_pending"/>

Decision guide

Business value: Makes ordered fallback decisions visible and deterministic.

  • Use when

    • A condition block has another mutually exclusive business case.
  • Choose another approach when

    • This is the first branch or unconditional fallback.
  • Prerequisites

    • Place it after if or another else-if in a condition block.
  • Alternatives

    • Use if for the first conditional branch. (See: <if>)
    • Use else for the unconditional final fallback. (See: <else>)

Complete examples

Assemble nested objects, conditional lists, arrays, and branches

Use this shape when one deterministic product combines nested records, heterogeneous list entries, literal arrays, and mutually exclusive fields.

structured-profile/datamimic.xml
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<setup rngSeed="42" numProcess="1">
    <generate name="profiles" count="3" target="LogExporter">
        <key name="id" generator="IncrementGenerator"/>
        <nestedKey name="address" type="dict">
            <key name="city" constant="Berlin"/>
            <key name="postal_code" constant="10115"/>
        </nestedKey>
        <list name="contacts" converter="RemoveNoneOrEmptyElement">
            <item>
                <key name="channel" constant="email"/>
                <key name="value" script="'customer-' + str(id) + '@example.test'"/>
            </item>
            <item condition="id % 2 == 0">
                <key name="channel" constant="sms"/>
                <key name="value" script="'+49-30-' + str(100000 + id)"/>
            </item>
        </list>
        <array name="roles" type="literal">
            <value constant="customer"/>
            <value constant="newsletter"/>
        </array>
        <condition>
            <if condition="id == 1">
                <key name="segment" constant="new"/>
            </if>
            <else-if condition="id == 2">
                <key name="segment" constant="active"/>
            </else-if>
            <else>
                <key name="segment" constant="loyal"/>
            </else>
        </condition>
    </generate>
</setup>

Rules and invalid combinations

I506 — Condition Eval Failed

Failed to evaluate condition '{condition}' for {element_label}: {error}

Why: The system failed to evaluate condition '{condition}' for {element_label}: {error}.

Resolution: Fix the expression or script and retry.

Full rule

I507 — Condition Not Boolean

Condition '{condition}' for {element_label} evaluated to a non-boolean value (not a valid boolean value): {value}

Why: A condition evaluated to a non-boolean value in the condition configuration.

Resolution: Ensure the expression evaluates to true or false.

Full rule

Allowed parents / Allowed children

Allowed parents: condition, else, else-if, if, while

Allowed children:

All registered DSL elements.

  • Structured Data and Rule Pipelines — Shows how composite output shapes and the ordered source-filter, mapping, and target-filter pipeline work together without hiding phase boundaries.

Attributes

Show all 1 attributes

condition

Condition to evaluate.

required; string.