Element <while>¶
Purpose: Repeat child statements while a condition is true, subject to an iteration limit.
Why: Use it for a bounded per-row loop only when repeated child execution cannot be expressed directly.
Example¶
1 | |
Decision guide¶
Business value: Expresses bounded repeated child execution when the stopping condition is data-dependent.
-
Use when
- A row-level workflow must repeat until an explicit condition or bound is reached.
-
Choose another approach when
- A fixed count, collection, or direct expression can represent the repetition.
-
Prerequisites
- Provide a terminating condition and a safe maximum iteration bound.
-
Alternatives
- Use generate for fixed or source-derived record counts. (See:
<generate>) - Use list for a bounded collection assembled without a loop. (See:
<list>)
- Use generate for fixed or source-derived record counts. (See:
Complete examples¶
Repeat a row-local operation under an explicit stop condition
Use while only for bounded iterative logic that cannot be expressed as direct field dependencies; echo is useful while diagnosing that loop, not as an exporter.
| bounded-loop/datamimic.xml | |
|---|---|
1 2 3 4 5 6 7 8 9 10 | |
Rules and invalid combinations¶
No additional element-specific rules. Required attributes, types, and supported values are shown below.
Allowed parents / Allowed children¶
Allowed parents: else, else-if, generate, if, iterate, nestedKey, while
Allowed children:
All registered DSL elements.
Attributes¶
Show all 2 attributes
condition
Condition to evaluate before each loop iteration.
required; string.
maxIterations
Maximum number of iterations before raising an error (default 10000).
optional; integer; Default: null.