Sections, Loops & Logic
Flow blocks control order and routing while preserving the canonical answer model.
Conditions
Use if for compact expressions and <condition> for multi-line code that returns a boolean-like value.
<question type="single" name="TARGET" if="AGE.value >= 18 && BRAND.has(1)">
<description>Targeted question</description>
</question>
Runtime condition errors fail open so respondents can continue and missing cases are minimized.
Jump
<jump to="TARGET" title="Route to target" if="Q1.o1">
<condition>
return Q1.o1 && AGE.value >= 18;
</condition>
</jump>
If the condition is true, Survey Link moves to the page containing the target block. Hidden targets resolve to the next visible flow block.
Sections and loops
Sections can reorder child blocks. Loops repeat blocks by item, and loop order metadata is tracked through system order fields for runtime and simulation analysis.
Section example
<section name="SEC_ROTATE" title="Rotating diagnostic section" order="rotation">
<question type="single" name="SEC_Q1"><description>Section item 1</description><option value="1">Yes</option></question>
<question type="text" name="SEC_Q2"><description>Section item 2</description></question>
</section>
Sections preserve answer names. order="random" or order="rotation" changes presentation order only.
Loop example
<loop name="BRAND_LOOP">
<items order="rotation" group-order="random">
<group name="PRIMARY">
<label>Primary brands</label>
<item name="1">Brand A</item>
<item name="2">Brand B</item>
</group>
</items>
<question type="rating" name="BRAND_RATE_{{item}}" mode="star" score="5">
<description>Rate {{item_label}}</description>
</question>
</loop>
Loop placeholders are expanded per item. Keep loop item names stable because they become part of generated question names and export columns.
Share list example
<share-list name="CORE_OPTIONS">
<group name="CORE_GROUP"><label>Core</label><option value="1">One</option></group>
</share-list>
<question type="single" name="USES_SHARE_LIST">
<description>Shared options</description>
<options><insert-list from="CORE_OPTIONS" /></options>
</question>
<insert-list> preserves the authored reference while runtime expands the reusable option/attribute tree for rotation, validation, and export metadata.