Conditions and applied conditions
The <Condition> and <ConditionSet> elements in Styles.xml, the attributes our parser reads from them, and how a run opts in through AppliedConditions.
Conditional text is wired through a <Condition> toggle, an optional <ConditionSet> that groups toggles, and an AppliedConditions attribute that attaches a run to one or more conditions.
In short: Three named pieces make conditional text work in IDML. A
<Condition> defines an on/off visibility toggle, an optional <ConditionSet>
groups several toggles for an editor, and an AppliedConditions attribute on a
run names the conditions that govern it. The <Condition> and <ConditionSet>
elements live once at the document level in Resources/Styles.xml; the
AppliedConditions attribute lives on a <CharacterStyleRange> inside a story.
This page is the reference for each of these — the attributes our parser reads,
which ones drive layout, and how a run opts in.
Conditional text is wired through three named pieces: a <Condition> that defines
a toggle, an optional <ConditionSet> that groups toggles, and an
AppliedConditions attribute that attaches a run to one or more conditions. The
first two live in Resources/Styles.xml; the third lives on a
<CharacterStyleRange> inside a story.
The example below is one story with two runs. The first carries no condition; the
second names Condition/Draft, which the document declares Visible="false".
Because that condition is hidden, the second run is dropped before layout: our
parser reads two runs from the story, but the rendered page reports one.
A run tagged with a hidden condition — present in the XML, absent from the page.
Stories/Story_ustory.xml<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<idPkg:Story xmlns:idPkg="http://ns.adobe.com/AdobeInDesign/idml/1.0/packaging" DOMVersion="20.0">
<Story Self="ustory">
<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/$ID/[No paragraph style]">
<CharacterStyleRange AppliedCharacterStyle="CharacterStyle/$ID/[No character style]">
<Content>Ship this. </Content>
</CharacterStyleRange>
<CharacterStyleRange AppliedCharacterStyle="CharacterStyle/$ID/[No character style]" AppliedConditions="Condition/Draft">
<Content>DRAFT — do not print.</Content>
</CharacterStyleRange>
</ParagraphStyleRange>
</Story>
</idPkg:Story>
<Condition>
A document-level visibility toggle, declared once in Resources/Styles.xml
alongside the style groups. Its Self id is the value a run refers to in
AppliedConditions. Our parser reads the four attributes below; the remaining
indicator-appearance attributes and the IndicatorColor child are read past, not
acted on, because the renderer never draws the indicator (see
visibility resolution).
| Attribute · Condition | Type / values | Support | Notes |
|---|---|---|---|
| Self | string id (e.g. "Condition/Draft") | Supported | The condition id. This is what a run names in AppliedConditions. |
| Name | string | Supported | The human-readable condition name shown in an editor. Required by the format; the renderer keys off Self, not Name. |
| Visible | boolean | Supported | Whether the condition is currently on. Absent means visible — a missing or unparseable value is treated as true. |
| IndicatorMethod | None | Underline | Highlight | Parsed, not yet rendered | How an editor should flag the governed text. Captured for round-trip; never drawn on the page. |
Visible is the only attribute the layout pass reads. When it is false, every
run that names this condition is removed; when it is true or absent, those runs
are kept. There is no inheritance and no cascade here — the value on the
<Condition> element is the whole story.
AppliedConditions on a run
A <CharacterStyleRange> opts in to conditions through a single
AppliedConditions attribute: a space-separated list of <Condition>
references. A run with no AppliedConditions (the common case) is never gated and
is always laid out.
| Attribute · CharacterStyleRange | Type / values | Support | Notes |
|---|---|---|---|
| AppliedConditions | space-separated Condition/… refs | Supported | The conditions governing this run. The run is laid out only when every referenced condition resolves to Visible; if any is hidden, the whole run is dropped. |
The combination is AND: listing two conditions means the run survives only
when both are visible. A reference that does not resolve to any declared
<Condition> is treated as visible (an unknown name cannot hide a run), so a stray
or mistyped condition id never silently removes text.
<ConditionSet>
A <ConditionSet> is a named grouping of conditions — the unit an editor's
Conditions panel toggles together (for instance, a "Print preview" set that flips
several conditions at once). It also lives in Resources/Styles.xml. Our parser
reads it for round-trip fidelity, but the layout pass does not branch on it: a run
is gated by the individual conditions it names, never by which set is "active". See
visibility resolution for why.
| Attribute · ConditionSet | Type / values | Support | Notes |
|---|---|---|---|
| Self | string id | Parsed, not yet rendered | The set id. Stored; not consulted during layout. |
| Name | string | Parsed, not yet rendered | The set name shown in an editor. |
| Conditions | space-separated Condition/… refs | Parsed, not yet rendered | The conditions collected into this set, stored as-parsed. The renderer does not use set membership to decide visibility. |
With the three pieces in hand — a condition that defines a toggle, a run that names it, and the visibility value that decides the outcome — the next page walks the resolution rule end to end and pins down which parts are drawn and which are not.
Frequently asked questions
Which attribute on <Condition> decides whether text is shown?
Visible is the only attribute the layout pass reads. When it is false, every
run that names the condition is removed; when it is true or absent, those runs
are kept. There is no inheritance or cascade — the value on the element is the
whole story.
How does a run reference more than one condition?
Through a single AppliedConditions attribute holding a space-separated list of
<Condition> references. The combination is AND: the run survives only when every
referenced condition resolves to visible, so naming two conditions means both must
be on for the run to be laid out.
What happens if AppliedConditions names a condition that does not exist?
An unresolved reference is treated as visible, so a stray or mistyped condition id
never silently removes text. It takes a declared <Condition> with Visible="false"
to hide a run.
Does a <ConditionSet> control what gets rendered?
No. Our parser reads <ConditionSet> for round-trip fidelity, but the layout pass
never branches on set membership. A run is gated only by the individual conditions
it names, never by which set an editor considers "active".
Conditional text
Conditional text lets one IDML document carry several versions of its words, with runs shown or hidden depending on whether a named condition is visible.
Visibility resolution
How our renderer decides whether a conditional run is laid out — the drop-before-layout rule, and the editor-only pieces it deliberately leaves undrawn.