XFA Specification
Chapter 3, Object Models in XFA
Scripting Object Model
89
In the following example, the receipt template is changed to omit the
name
attribute from the detail
subforms.
Example 3.1
"name" omitted from subforms
<xdp …>
<template …>
<subform name="Receipt">
<subform>
<field name="Description" …> … </field>
<field name="Units"> … </field>
<field name="Unit_Price" …> … </field>
<field name="Total_Price" …> … </field>
</subform>
<subform>
<field name="Description" …> … </field>
<field name="Units"> … </field>
<field name="Unit_Price" …> … </field>
<field name="Total_Price" …> … </field>
</subform>
<field name="Sub_Total" …> … </field>
<field name="Tax" …> … </field>
<field name="Total_Price" …> … </field>
</subform>
</template>
</xdp>
In the above example, the
Description
field for the first detail subform is referenced in the Form DOM
as:
$form.Receipt.Description[0]
while the
Description
field in the second detail subform is referenced as:
$form.Receipt.Description[1]
Similarly in the Template DOM the references would be:
$template.Receipt.Description[0]
and
$template.Receipt.Description[1]
It is as though the nameless subform was removed and its children adopted by the nameless subform's
parent. This has the side-effect of making fields into siblings that would not otherwise be siblings. For the
Total_Price
fields all three become siblings for purposes of SOM expressions even though they are
physically at different levels in the tree.
Nameless template and form objects cannot partake in the full set of functions that named objects
partake in. Rather, nameless subforms are usually inserted simply to wrap around another object in order
to lend the subform's richer capabilities to the enclosed object. For example, fields do not have
occur
properties but subforms do. As a result, it is normal to wrap a field inside a nameless subform in order to
place the field under the influence of an
occur
property. Similarly, nameless exclusion groups are mere
wrappers around sets of fields; the actual data values belong to the fields, not to the nameless exclusion
group. In the same way, all nameless template and form objects are second-class objects, of interest to the
form creator but not corresponding to data or to anything visible. The SOM expression resolver makes
Home Index Bookmark Pages
Pages: Home Index All Pages