XFA Specification
Chapter 3, Object Models in XFA
Scripting Object Model
96
The Parent Property
Every object except the
xfa
object has a property called parent that points to the object's parent node.
When parent is used in a SOM expression, it has the effect of forcing the expression resolution to go back
up the tree one level. This is analogous in function to the
"/.."
or
"\.."
constructs often used in file
names. However, it should be emphasized the similar syntax
".."
has quite a different meaning in XFA
SOM expressions, as described in
“Selecting Descendants At Any Level” on page 96.
Instead the function
of going up one level is performed by
".parent"
. For example, given the receipt data, the expression
$data.Receipt.Detail.parent.Tax
is equivalent to
$data.Receipt.Tax
This facility works in any DOM but is much more useful when used with unqualified references in the Form
DOM.
The
xfa
object also has a parent property, but its value is null.
Selecting Descendants At Any Level
The syntax
".."
can be used to select the first descendant in document order at any level which matches
the subsequent portions of the expression. The resolution of such expression requires additional
computation, so their use may adversely impact performance.
Example 3.3
Receipt data
<?xml version="1.0" encoding="UTF-8" ?>
<Receipt>
<Detail>
<Description>Giant Slingshot</Description>
<Units>1</Units>
<Unit_Price>250.00</Unit_Price>
<Total_Price>250.00</Total_Price>
</Detail>
<Detail>
<Description>Road Runner Bait, large bag</Description>
<Units>5</Units>
<Unit_Price>12.00</Unit_Price>
<Total_Price>60.00</Total_Price>
</Detail>
<Sub_Total>310.00</Sub_Total>
<Tax>24.80</Tax>
<Total_Price>334.80</Total_Price>
</Receipt>
In the above example, both of the following expressions
$data..Total_Price
$data..Total_Price[0]
resolve to
$data.Receipt.Detail.Total_Price
, the first matching node in document order. The
value of this node is 250.00. Note that once this first match is found, the SOM expression resolver does not
look at any other branches of the SOM. In particular, the expression
$data..Total_Price[1]
does not
match any node, because there is no node corresponding to
$data.Receipt.Detail.Total_Price[1]
.