XFA Specification
Chapter 3, Object Models in XFA
Scripting Object Model
91
$template.Receipt.#subform[1]
Note:
When an index is used with the
"#class"
syntax, the index refers to all occurrences of true siblings
of that class, whether they are named or not.
Explicit naming is available as an option in the Data DOM. However, in the Data DOM, the element tag is
taken as the name by default, but may be overridden by the content of an attribute. Thus, nodes in the
Data DOM always have names, one way or the other. See the
“XFA Names” on page 70
for a description of
the explicit naming option and how to invoke it. Consequently the
"#"
syntax is not usually needed for
nodes in the Data DOM. One case in which it is needed is when the element tag contains characters that
are not allowed in the names of objects by the scripting language. For example, FormCalc does not
support object names containing a minus (
"-"
) character. If such an element is loaded into the Data DOM
without mapping the name to something else (another load option), the resulting
dataGroup
or
dataValue
object cannot be referenced using the usual syntax. In such a case, it is necessary to use
#dataGroup
or
#dataValue
, respectively.
The
"#class"
syntax can also be used for objects that cannot be explicitly named, although it is
redundant. For example, when referring to the following configuration information
<xdp …>
<config …>
<present …>
<copies>4</copies>
…
</present>
</config>
</xdp>
The SOM expression
$config.present.copies
is equivalent to
$config.present.#copies
.
Attributes
Attributes are accessed using the same syntax as elements. Instead of the element tag/object class use the
attribute name.
For example:
<xdp …>
<connectionSet xmlns="http://www.xfa.org/schema/xfa-connection-set/2.4/">
<wsdlConnection name="ShoppingCart"
dataDescription="cartDD">
…
</wsdlConnection>
<wsdlConnection name="Catalogue" … >
…
</wsdlConnection>
<wsdlConnection name="Shipping" … > … </wsdlConnection>
<xmlConnection name="TsAndCs" … > … </xmlConnection>
</connectionSet>
</xdp>
The
dataDescription
attribute of the
wsdlConnection
named
ShoppingCart
can be referenced in
a SOM expression as:
$connectionSet.ShoppingCart.dataDescription