XFA Specification
Chapter 23, FormCalc Specification
Grammar and Syntax
818
Aside from a referral to the absolute occurrence of an object, there also exists the need to refer to the
relative occurrence of an object, and to all occurrences of an object. To that end,
FormCalc
uses the
notation:
Notation
Identifier
Refers to …
An occurrence of the object that bears the same
ordinal occurrence number as the referencing
object.
The occurrence of the object identifiedby the
runtime value of the expression.
N'th
succeeding
occurrence of the object identified
by the runtime value of the expression, relative to
the referencing object's occurrence number.
N'th
preceding
occurrence of the object identified
by the runtime value of the expression, relative to
the referencing object's occurrence number.
Every occurrence of the identified object.
Identifier[ SimpleExpression ]
Identifier[+ ( SimpleExpression )]
Identifier[- ( SimpleExpression )]
Identifier[*]
Thus,
Identifier[0]
refers to the first occurrence of the identified object, and by
convention,
Identifier[+0]
and
Identifier[-0]
refer to the object whose occurrence number is
the same as the referencing object.
The notation
Identifier [ SimpleExpression ]
involves an indexing operation, which must yield
a numeric result. If the SimpleExpression
67
operand is non-numeric, then it will be promoted to a number
using the rule for a SimpleExpression; if the non-numeric indexing operand can be fully converted to a
numeric value then that is its value; otherwise its value is zero (0), and, when promoting a null-valued
indexing operand to a number, its value is always zero.
Some accessor expressions can often evaluate to a set of values, and some built-in functions, such as the
following, are designed to accept a set of values.
Avg()
Count()
Max()
Min()
Sum()
Concat()
However, it is not always possible to determine the exact number of arguments passed to a function at
time of compilation. For example, consider the following form calculation
Max(Price[*])
. If there are
no occurrences of object
Price
, then the function
Max()
will generate an error exception. If there is a
single occurrence of object
Price
, then the function
Max()
will return the value of that object
occurrence. If there are multiple occurrences of object
Price
, then the function
Max()
will return the
maximum value of all those object occurrences.
For all occurrences of a given object to be included in a calculation, the object must be specified using the
[*]-style of accessor referral.
Expression
Sum(Price[*])
Sum(Price)
Result
Sums all occurrences of object
Price
Sums a single occurrence of object
Price
In most other built-in functions, the description of the formal arguments stipulates that it must be a single
value, but it may be that the passed argument evaluates to a set of values. In such circumstances, the