XFA Specification
Chapter 3, Object Models in XFA
Scripting Object Model
111
the expression
B.#subform
resolves to
$form.root.B.#subform[1]
. The index
"[1]"
is copied
from the corresponding level in the current object's full name, which is
$form.root.A.#subform[1].C
.
Relative Index
Sometimes it is necessary for a script associated with one cell in an array to refer to another cell on another
line above or below. A special syntax is provided for this. Within an unqualified reference an index of the
form
"[-nnn]"
is interpreted as the current container's index minus
nnn
, while an index of the form
"[+nnn]"
is interpreted as the current container's index plus
nnn
. For example, in the following template
the first
Item_No
field defaults to
1
. After than each
Item_No
field is automatically set to one more than
the previous
Item_No
field. Hence, if the user manually enters a value into the first
Item_No
field all
subsequent fields are automatically updated.
<xdp …>
<template …>
<subform name="Receipt" …>
<field name="Item_No" …>
<value>
<integer>1</integer>
</value>
</field>
<field name="Description" …> … </field>
<field name="Units" …> … </field>
<field name="Unit_Price" …> … </field>
<field name="Total_Price" …> … </field>
<field name="Item_No" …>
<calculate>
<script>Item_No[-1] + 1</script>
</calculate>
</field>
<field name="Description" …> … </field>
<field name="Units" …> … </field>
<field name="Unit_Price" …> … </field>
<field name="Total_Price" …> … </field>
</subform>
</template>
</xdp>
Relative indexing can also be used with inferred indexes. Relative indexes are defined as relative to the
unadorned reference. Hence the full meaning of
"[-nnn]"
is "indexed by
nnn
less than what it would
have been if
[-nnn]
had not been specified". Similarly the full meaning of
"[+nnn]"
is "indexed by
nnn
more than it would have been if
[+nnn]
had not been specified".
Relative indexing
cannot
be used in fully-qualified SOM expressions because such expressions cannot infer
indexes.
SOM Expressions That Reference Variables Properties
SOM expressions may reference values or named script objects specified in
variables
properties.
Variables may be used to hold boilerplate or image references or to define script object references.
Because SOM expressions that reference variable properties usually appear in calculation or validation
scripts, their use is described in
“Document Variables” on page 294.
Home Index Bookmark Pages
Pages: Home Index All Pages