Conditional chaining¶
The || operator joins rules into a fallback chain: if the first rule fails
to produce a mapping, the second rule runs against the same input, and so
on. This is invaluable when the source data has multiple plausible mappings
and the engine should try them in priority order.
Pre-map plus vocabulary lookup¶
A common pattern: a Map supplies
hand-curated codes for the values that the vocabulary cannot resolve, and a
VocabMap handles the rest:
If Map finds the input value, its replacement flows on. Otherwise
VocabMap runs against the original input.
Two parallel maps with a Selector¶
The pre-map approach above only works if the chosen vocabulary actually has
a code you can pre-map to. When that is not the case, the alternative is to
run two independent rules into separate variables and combine with
Selector — but this approach
is slower and harder to read than || and should be reserved for
genuinely independent mappings.
Family restrictions¶
- Mapping rules can only be
||-chained with other mapping rules. - Aggregating rules can only be
||-chained with other aggregating rules. - Not every rule supports
||chaining. Each rule's reference page declares whether it does (look forsupports ||in the meta line).
Multi-step chains¶
Conditional chains can have any number of rules — the engine walks them in order until one succeeds:
The final entry can be a Map with a default value as a catch-all that
guarantees a successful mapping.