XFA Specification
Chapter 8, Dynamic Forms
Data Binding for Dynamic Forms
275
Subform Set
An individual dynamic subform can be omitted or included in response to the presence or absence of data
in the Data DOM. A subform set imposes additional constraints upon the inclusion or omission of the set of
subforms and/or subform sets which it encloses.
There are three types of subform sets, distinguished by the value of the
relation
attribute. The relation
attribute can have any of the values
choice
,
ordered
, and
unordered
.
A choice subform set encloses a set of mutually-exclusive subforms and/or subform sets. Even if the Data
DOM contains matches for more than one of the members of the set, only one will be copied into the Form
DOM. The one chosen is the first matching one encountered in the Data DOM, when descending it in data
order, that is, width-first and oldest to newest (left to right). If there is no match none of the members are
included, leaving the subform set node in the Form DOM without any children.
An unordered subform set encloses subforms and/or subform sets that have no special ordering in the
template. The whole set is copied into the Form DOM, however the ones (if any) that match data groups
are copied first, in data order. The rest are copied in template order.
An ordered subform set encloses subforms and/or subform sets that have a special ordering in the
template. The whole set is copied into the Form DOM in template order, and then matching data nodes (if
any) are bound to them. An ordered subform set is functionally equivalent to a subform with no name.
Subform sets have initial, min, and max occurrence attributes just like the subforms that belong to the set.
During an empty merge the initial attribute of the subform set determines how many copies of it are
added to the Form DOM, and then the initial attributes of the subforms determine how many copies of
each are added to the Form DOM under each copy of the subform set, except for choice subform sets.
When a choice subform set is added to the Form DOM only the first of its subforms is copied to the Form
DOM regardless of the occurrence attributes of the rest. For example, the following shows a portion of a
template for a pizza order. There is a separate subform for each type of pizza topping because each type
has different options. Pepperoni can be mild or hot, green peppers can be sliced or chopped, and olives
can be green or black. The pizza toppings are contained by an ordered subform set:
<subformSet name="topping" relation="ordered">
<subform name="pepperoni">
<occur initial="2"/>
…
</subform>
<subform name="greenPeppers">
<occur initial="1"/>
…
</subform>
<subform name="olives">
<occur initial=”0”/>
… </subform>
</subformSet>