XFA Specification
Chapter 3, Object Models in XFA
Scripting Object Model
106
<field name="Total_Price"> … </field>
</subform>
</template>
</xdp>
the expression
$.Sub_Total
resolves unambiguously to
$form.Receipt.Detail.Sub_Total
.
Scope-matching does not apply hence the expression does
not
resolve to the same-named field
$form.Receipt.Sub_Total
.
"$"
can also be used for expressions pointing to nodes that are higher up in the hierarchy than the script's
container. Use
"$.parent"
,
"$.parent.parent"
, and so on to climb levels in the tree. It is possible to
climb all the way to the root. The equivalent syntax for native ECMAScript expressions is
"this.parent"
,
"this.parent.parent"
, and so on.
Inferred Index
The previous sections have used as examples a template that is divided up into individual subforms for
each detail record. Conceptually such a template is arranged in a tree structure. However it is also possible
to create templates that are notionally arranged in a matrix, like a spreadsheet. For example:
<xdp …>
<template …>
<subform name="Receipt" …>
<field name="Description" …> … </field>
<field name="Units" …> … </field>
<field name="Unit_Price" …> … </field>
<field name="Total_Price" …> … </field>
<field name="Description" …> … </field>
<field name="Units" …> … </field>
<field name="Unit_Price" …> … </field>
<field name="Total_Price" …> … </field>
<field name="Description" …> … </field>
<field name="Units" …> … </field>
<field name="Unit_Price" …> … </field>
<field name="Total_Price" …> … </field>
<field name="Description" …> … </field>
<field name="Units" …> … </field>
<field name="Unit_Price" …> … </field>
<field name="Total_Price" …> … </field>
<field name="Description" …> … </field>
<field name="Units" …> … </field>
<field name="Unit_Price" …> … </field>
<field name="Total_Price" …> … </field>
</subform>
</template>
</xdp>
Instead of grouping the fields by subform, this static template simply repeats each of the
Description
,
Units
,
Unit_Price
, and
Total_Price
fields five times. Most likely these are arranged on the page as a
matrix four fields wide and five lines high, in imitation of a traditional pre-printed paper form.
SOM expressions provide a mechanism to deal conveniently with such arrangements. When
scope-matching, if an unqualified reference is made without specifying an index, the index of the
Home Index Bookmark Pages
Pages: Home Index All Pages