XFA Live Child Collections
JavaScript and FormCalc events can inspect the current child nodes of a form node or property node through its read-only nodes property
const field = xfa.resolveNode("row[1].amount");
const children = field.font.nodes;
const snapshot = children.clone();
field.font.fill.color.value = "192,48,96";
const fill = children.item(0);
Reading current children
| Member | Behavior |
|---|---|
length | Current number of child nodes |
item(index) | Current child at that zero-based index, or null for a negative, noninteger, or out-of-range index |
namedItem(name) | First current child with that literal name, or null when no child matches |
nodes[index] | Same current node as item(index) |
for...of | Read child nodes in their current order |
clone() | Create an independent query list referencing the current children |
The collection resolves its owner through the current event graph on each read, including a collection retained by a script object across events
Existing collections reflect repeated-instance additions and removals and implicit property creation; separate repeated instances keep separate property children and values
A retained collection whose owner was removed raises an error instead of targeting a surviving or replacement instance
FormCalc access
FormCalc recognizes nodes as a child-collection property on form, property, and Data DOM nodes
if (xfa.record.nodes.length >= 2) then
xfa.record.nodes.item(1).nodes.namedItem("amount").rawValue = "Updated"
endif
Direct length, item(index), namedItem(name), and clone() member chains use the same current native nodes and collection limits as JavaScript
Form, property, and Data DOM child collections support direct nodes[index] reads in both JavaScript and FormCalc
Collection indices are zero-based; for...of remains JavaScript syntax
Writes through a FormCalc collection reference update the actual bound data value and retain repeated-instance isolation; committed values survive XDP saving, runtime reloading, and native PDF appearance generation
Data DOM numeric indices
const rows = xfa.record.nodes;
rows[1].nodes[0].rawValue = "Updated";
Canonical nonnegative integer keys such as "0" and "1" resolve the current Data DOM child and return null outside the collection; noncanonical keys such as "01", "-0", and "1.0" do not alias numeric entries
JavaScript index in nodes checks the current child count, and direct assignment, deletion, or redefinition of a canonical numeric entry raises TypeError
The same numeric-entry restrictions apply inside a script object function that retains the collection in lexical state, as well as when another event reads a collection returned by that function
Use the existing Data DOM structural methods to reorder or remove children; a collection retained by a script object reads the current event graph after each committed edit and after rollback
Independent clones
A cloned child list uses the independent storage described in XFA Query Node Collections; its append, insert, and remove methods change that independent storage
Writing a node referenced by either list changes the actual native node, and committed values and property overrides persist through saved XDP and native PDF appearance generation
Data DOM child collections also provide clone() with independent entry storage; their existing structural append, insert, and remove methods continue to mutate the native data tree
Transactions and limits
Live collection objects and independent clones share the event collection allocation limits, operation checks, and transaction deadline
An uncaught event error or budget failure restores native values, repeated instances, retained script state, independent list storage, and journal state together
Form and property live collections are read-only; direct assignment, deletion, property redefinition, prototype changes, and preventing extensions raise an error
Data DOM collections reject writes, deletion, and redefinition of canonical numeric entries while retaining their existing named structural methods and ordinary nonnumeric property behavior
Coverage
This interface exposes current form and property child collections and independent child-list clones
General template/form node creation, recursive node cloning, child-tree insertion and removal, and additional node-class bindings remain separate work