XFA Specification
Chapter 3, Object Models in XFA
Document Object Models
71
Document Object Models
General Information
A Document Object Model (DOM) is a platform- and language-neutral interface that allows programs and
scripts to dynamically access and update the content, structure and style of a document. DOMs are
commonly used with data expressed in XML. Indeed the preceding definition of a DOM is paraphrased
from the W3C XML DOM standard [XMLDOM2].
In this specification many operations are described in terms of their effects upon the DOMs. This permits
the specification to be detailed enough for implementation without imposing any requirement upon the
language used for the implementation. Although the contents of a DOM are sometimes referred to as
objects, this terminology does not mean that implementations must be written in an object-oriented or
even object-based language.
However XFA does include scripting facilities. Both of the scripting languages currently defined for use
with XFA are object-based. Hence, in order to make scripts interoperate across different XFA
implementations a common object models must be presented. Furthermore, almost the entirety of the
various DOMs are exposed to scripts. Hence, although an implementation need not be object-based
internally it must present to scripts an object-based API covering most of its functionality.
All of the DOMs used in XFA share the following characteristics:
They are strictly tree-structured.
A node may have mandatory children. In such cases the mandatory child nodes are created at the same
time as their parent.
The non-mandatory children of each node in the tree are ordered by age. That is, the DOM is aware of
the order in which the non-mandatory child nodes were added.
There are many DOMs in XFA. The large number arises because XFA exposes almost all processing. For
each step in processing there is a DOM holding the data structures for that stage. Scripts can examine and
modify each DOM. DOMs are responsible for maintaining internal consistency but not external
consistency. For instance, when a script turns on a radio button by assigning to the corresponding field, all
the other buttons coupled to that one are automatically turned off. This is a matter of internal consistency
so it is managed by the Form DOM itself. By contrast the XFA Data DOM does nothing to prevent a script
violating the rules of XML, for instance by giving an element two attributes with the same name. This is a
matter of external consistency so it is the responsibility of the script author, not the DOM.
Hierarchy of DOMs
The XFA DOM encapsulates all but one of the other DOMs. The root nodes of most of the other DOMs are
children of the root node of the XFA DOM. All but one of the remaining root nodes are grandchildren of
the root node of the XFA DOM. The only DOM used in XFA that is not inside the XFA DOM is the XML Data
DOM.
Note:
If an application has more than one form open simultaneously, each open form has its own separate
XFA DOM. There is no way for an expression or script in one form to refer to another form.
This encapsulation is convenient for scripting. Scripts refer to nodes in the DOM using XFA Scripting Object
Model (XFA-SOM) expressions. All of the DOMs contained within the XFA DOM can be referenced using a
uniform syntax. The XML Data DOM, because it is not inside the XFA DOM, is not directly accessible to
Home Index Bookmark Pages
Pages: Home Index All Pages