XFA Specification
Chapter 3, Object Models in XFA
Scripting Object Model
93
<field name="x" …> … </field>
<field name="y" …> … </field>
</subform>
</template>
The expression
$template.Detail.x
refers to the explicitly named object which is the field named
x
. By contrast the expression
$template.Detail.#x
returns the attribute
x
on Detail, which has a value of
7.76mm
.
In the next example, the subform has a
name
attribute which is set to
Detail
. However it also contains a
field element which is explicitly named
name
.
<xdp …>
<template …>
<subform name="Detail">
<field name="name">Ernest</field>
</subform>
</template>
</xdp>
The XFA SOM expression
$template.Detail.name
returns the value of the field named
name
, which is
Ernest
, because XFA SOM resolves the name clash in
favor of the explicit naming of the field, rather than the automatic naming of the subform's attribute.
To access the
name
attribute of Detail, use ".
#".
For example,
$template.Detail.#name
returns the value of the property
name
on the
Detail
subform which is the string
Detail
.
Note that there is no way to disambiguate clashes between attribute names and child element tags or
internal properties. XFA schemas, such as the template schema, are constructed in such a way as to
prevent such clashes. User data cannot be so constrained. Instead, in the Data DOM the situation is
handled by treating attribute values as just another type of content, so that array-subscripting can be used
to select the desired node. For example, assume attributes are being loaded into the Data DOM and the
data is:
<Receipt Detail="Acme">
<Detail> … </Detail>
<Detail> … </Detail>
</Receipt>
In the Data DOM this is handled by creating three separate nodes which are siblings. The first node (eldest
sibling) represents the Detail attribute with the value Acme. The second node (middle sibling) represents
the first Detail element. The third node (youngest sibling) represents the second Detail element. Hence
either of the expressions
$data.Receipt.Detail
$data.Receipt.Detail[0]
Home Index Bookmark Pages
Pages: Home Index