XFA Specification
Chapter 9, Automation Objects
Calculations
297
xfa.form.form1.foo.y);
</script>
</calculate>
</field>
</subform>
</template>
After the XFA processing application completes data binding the above template, it executes the resulting
form’s calculations. If those calculations are executed in the order f1 to f4, the following results occur:
1. The data binding algorithm instantiates the subform named
form1
, which interns creates an instance
of the script object
foo
, by compiling the contents of script element.
2. The calculation on the field named
f1
fires, setting variables on
foo
to
x = 2
,
y = 2
and
factor = 2
.
3. The calculation on the field named
f2
fires, which calls the
sum
function on
foo
((2+2)* 2), resulting in
the field value being set to 8.
4. The calculation on
f3
fires, setting variables on
foo
to
x = 4
,
y = 4
and
factor = 4
.
5. The calculation on
f4
fires, which calls the
sum
function on
foo
((4+4)* 4), resulting in the field value
being set to 32.
Note:
The above result sequence assumes the post-binding execution of calculations proceeds in order
from
f1
to
f4
. There is no guarantee that this will be the execution order.
Calculations
This section explains how the processing application supports the
calculate
element represented in
the Form DOM. It describes how the
calculate
element relates to other automation elements, when the
processing application activates calculation scripts, where it stores the result of the calculation, and how it
observes precedence in interconnected calculations.
The
“Template Specification”
describes the syntax of the
calculate
element.
About
The
calculate
element is one of the family of automation elements. The other automation elements are
event
and
validate
. Automation elements are procedural extensions to the XFA architecture.
The
calculate
element provides a means of calculating the value of a container element, with the
calculation being represented as a script. The parameters in such a script may include the values of other
container objects. The XFA processing application is responsible for updating the value of the container
element with the value returned from the calculate script, although this obligation does not apply to
subform
calculate
elements.
The
calculate
element can be a child of the container elements:
exclGroup
,
field
, and
subform
. It
specifies a script to use for calculating the value of its parent container, and it specifies override conditions.
Such conditions specify whether a processing application can allow a user to override a calculated value,
and if so, what types of warnings should be issued.
Home Index Bookmark Pages
Pages: Home Index All Pages