Zum Inhalt

Element <condition>

Zweck: Ist ein reiner Verzweigungscontainer ohne eigene Attribute.

Warum: Verwende dieses Element, um einen if-Zweig, optionale else-if-Zweige und einen optionalen Fallback zu gruppieren.

Beispiel

1
<condition/>

Entscheidungshilfe

Fachlicher Nutzen: Gruppiert eine geordnete exklusive Verzweigungsentscheidung als prüfbaren Workflowblock.

  • Verwenden, wenn

    • Wenn mehrere Kindelemente zu if-, else-if- und Fallback-Zweigen gehören.
  • Anderen Ansatz wählen, wenn

    • Wenn eine einzelne bedingte Zuweisung oder Validierung die Anforderung direkter ausdrückt.
  • Voraussetzungen

    • Beginne mit if, füge null oder mehr else-if-Zweige an und platziere else zuletzt.
  • Alternativen

    • Verwende mapping für eine einzelne geordnete Transformationsregel. (Siehe: <mapping>)

Vollständige Beispiele

Verschachtelte Objekte, bedingte Listen, Arrays und Zweige zusammensetzen

Verwende diese Form, wenn ein deterministisches Produkt verschachtelte Datensätze, heterogene Listeneinträge, Literal-Arrays und exklusive Felder kombiniert.

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>

Regeln und ungültige Kombinationen

I501 — Condition Duplicate If

Fail while parsing . Only one tag is allowed in .

Warum: A block contains more than one first branch, so branch order is ambiguous.

Lösung: Keep exactly one as the first child; add further conditions as children.

Vollständige Regel

I502 — Condition If Missing

Fail while parsing . Must have as the first tag.

Warum: A block has no initial branch to establish the first decision.

Lösung: Add exactly one as the first child.

Vollständige Regel

I503 — Condition Else After

Fail while parsing . Tag must be the last tag.

Warum: An branch is followed by another branch, but is the unconditional final fallback.

Lösung: Move after every and branch.

Vollständige Regel

I504 — Condition Else Duplicate

Fail while parsing . There can only be one tag at most.

Warum: A block contains more than one unconditional fallback branch.

Lösung: Keep at most one , after all and branches.

Vollständige Regel

I505 — Condition Invalid Tag

Invalid tag {tag} in .

Warum: The branch container accepts only , , and optional final children.

Lösung: Replace <{tag}> with a supported branch element or move it inside an existing branch.

Vollständige Regel

Erlaubte Elternelemente / Erlaubte Kindelemente

Erlaubte Elternelemente: else, else-if, generate, if, iterate, nestedKey, while

Erlaubte Kindelemente:

else, else-if, if

Attribute

Alle 0 Attribute anzeigen

Keine