XFA Specification
Chapter 6, Template Features for Designing Forms with Repeating Sections
Forms with Repeated Fields or Subforms
207
When printed or displayed, the result is the same as the previous example (“Filled
Static Form as Printed”
on page 200).
However this method of constructing the form has an important drawback. Suppose that
John Brown’s first name is omitted from the data, as in example
“Membership data missing a field without
affecting the presentation” on page 204.
For convenience the example data is reproduced below.
<?xml version="1.0"?>
<Members>
<Date>01/01/04</Date>
<Last>Brown</Last>
<First>Betty</First>
<Last>White</Last>
</Members>
In this case, when data binding takes place, the data value
named
First
(containing “
Betty
”) is bound not to
$data.Members.First[1]
but to
$data.Members.First[0]
. The result is that the
membership list is printed as “
Betty Brown
” followed by a
member with no first name and a last name of “
White
”, as
shown at right.
This result comes about because when the data is not grouped
there is not enough information for the data binding algorithm
to resolve ambiguity. There are two approaches to fixing this
problem; either change the data document or use the data
regrouping facility in the data loader. The data regrouping
facility uses additional information supplied in the configuration
to parse a flat sequence of data values and transform it inside
the Data DOM into a series of data groups containing data
values.
See “The groupParent Element” on page 372.
Anytown Garden Club
2023 Anytown Road
Anytown, USA
Date
01/01/04
Membership List
Betty
Brown
White
Undesirable result when data is
missing and data is not grouped
Fixed Occurrence Numbers
A more concise way to represent static forms of this type is available. Subforms have an
occur
property,
which in turn has
max
,
min
, and
initial
sub-properties. By default these sub-properties are all 1
meaning that each subform occurs exactly once. However if they are all set to some other value
N
then the
meaning is that the subform occurs
N
times. This makes it unnecessary to repeat the subform declaration
N
times in the template. Thus the membership list example template can be expressed more concisely as
follows.
Example 6.18 Using fixed occurrence numbers
<template ...>
<subform name="Members">
<field name="Date" ...>...</field>
<subform name="Member">
<occur min="3" max="3" initial="3"/>
<field name="First" ...>...</field>
<field name="Last" ...>...</field>
</subform>
</subform>
</template>
This is fully equivalent to the earlier representation using three repetitions of the
Member
subform
declaration. The Form DOM that results from the data binding operation has the exact same structure
Home Index Bookmark Pages
Pages: Home Index All Pages