XFA Specification
Chapter 3, Object Models in XFA
Scripting Object Model
92
XML forbids more than one occurrence of a particular attribute per element, so it is never necessary to use
array-subscripting when referring to attributes.
The Data DOM does not by default load attributes, but there is an option to load attributes. See
“Creating,
Updating, and Unloading a Basic XFA Data DOM” on page 113
for more information about loading
attributes into the Data DOM.
Internal Properties and Methods
Scripting objects may have internal properties and methods that do not correspond to any XML element
or attribute. These are known as
transient
objects. For example, the
$event
object is created at run time to
hold the properties of whatever event is currently active. It can not be serialized to XML. Properties and
methods of such objects are referenced using the same
"."
notation used for attributes and classes. For
example, the following template fragment contains a script, activated by a mouse click on the field, that
checks a property of
$event
to determine whether the shift key was held down while the mouse button
was clicked:
<field name="Description">
<event action="click">
<script>if ($event.shift) then …</script>
</event>
</field>
$host
is another object that is purely internal. The following template fragment invokes a method of
$host
to set the keyboard focus when the user tabs out of a field:
<field name="Unit_Price">
<event action="exit">
<script>$host.setFocus(…)</script>
</event>
</field>
Some nodes have properties that may or may not correspond to an XML element or attribute. For example,
every subform and field has a locale property. When expressed in XML the corresponding element may
not have a locale declaration because it may inherit the locale of its parent subform. It is expected that
when an XFA application writes out data as XML it will eliminate redundant locale declarations where
possible. Nonetheless, to make scripting easier, every node in the Data DOM presents a locale property.
Hence the locale for the Tax element in the receipt example can be referenced as:
$form.Receipt.Tax.locale
It is beyond the scope of this specification to describe the properties possessed by different nodes in
different DOMs. For that information consult the scripting reference and the individual reference for each
DOM.
Name clashes
Name clashes can occur between names explicitly assigned via a
name
attribute and names automatically
generated from element tags, attributes, or internal properties. The
".#"
syntax can be used to resolve
such name clashes.
This example contains a name clash between an attribute name and the name explicitly assigned in a child
element.
<template>
<subform name="Detail" x="7.76mm" y="6.17mm" …>
Home Index Bookmark Pages
Pages: Home Index All Pages