XFA Query Node Collections

JavaScript and FormCalc events can inspect in-scope node occurrences and retain independent query lists across runtime events

const siblings = xfa.record.amount.all;
const retained = siblings.clone();
retained.remove(retained.item(0));
retained.insert(siblings.item(0), null);
retained.item(0).rawValue = "42";

Occurrence properties

node.all returns a fresh ordered query list of in-scope nodes with the same literal name; an unnamed node uses its class name instead

node.classAll returns a fresh ordered query list of in-scope nodes with the same class, including nodes with other names

node.index and node.classIndex return the zero-based occurrence within those respective scopes

Unnamed non-property containers are transparent to named scope lookup, including positive and negative relative SOM occurrences; property containers retain their own scope

Literal names such as #field, * and Unicode names are matched as authored names by these properties

Independent list operations

MemberBehaviour
lengthCurrent number of list entries
item(index)Referenced node, or null for a negative, noninteger or out-of-range index
namedItem(name)First referenced node with that literal name, or null when no node matches
clone()New independent entry storage that references the same nodes
append(node)Add the same live node reference at the end, including a duplicate reference
insert(node, before)Insert a live node reference before the first matching reference; null appends
remove(node)Remove the first matching reference; an absent reference raises an error

Lists returned by resolveNodes, all and classAll use independent entry storage; changing that storage leaves the form and data trees in place, whilst writing a referenced node changes the actual node

Form and property node.nodes collections expose live child views; their clone() methods return independent query lists, as described in XFA Live Child Collections

Data DOM node.nodes also supplies an independent clone(); its existing append, insert and remove methods retain their native structural behaviour, as described in Transactional XFA Data DOM Structure

Array iteration, indexed reads and enumeration expose referenced nodes; direct assignment, deletion, property redefinition, prototype changes and preventing extensions raise errors before changing the query list

Persistence and stable identities

Script objects can retain a query list or clone across events; each operation uses the current event resolver and transaction limits

Queried instance-manager handles route operations to the current event graph when retained or cloned across events

Renaming or reordering a surviving node keeps its retained list identity; removing a repeated form instance makes reads and writes through that removed reference fail instead of selecting a replacement instance

An independent list can clone its stored references and remove a previously retained removed-node reference without dereferencing that node

Query list storage is runtime script state; saving XDP persists the native node values and structure, whilst a new runtime starts a new script-object session

Transactions and limits

Invalid nodes and membership references fail before that list operation mutates storage; a caught error leaves earlier valid operations in the same event available

An uncaught event error, operation budget or elapsed-time failure restores query list mutations, native values, repeated instances, retained script-object state and journal state together, allowing the same runtime to retry

TXFAFormScriptLimits.MaxArrayItems bounds each retained list length and separately bounds cumulative list objects and newly allocated entries during one event; its zero setting uses the event context default of 65,536

Empty clones consume the object budget, nonempty clones also consume the entry budget, and retained lists remain bounded across separate successful events

FormCalc and PDF consumption

output = Concat(Sum(xfa.datasets.data.main.amount.all), ":",
  xfa.datasets.data.main.amount.all.length, ":",
  xfa.datasets.data.main.amount[1].classIndex)

FormCalc occurrence selection on literal xfa.form, xfa.datasets and xfa.record paths uses native SOM resolution; list indexing after a collection property indexes that collection

Save runtime bytes to XDP and pass them to HPDFXFAWriteHeadlessPDF to generate actual native fields and appearances from the committed values, including edits through retained surviving repeated-instance references

TXFAHeadlessPDFOptions.Editable = False creates read-only native fields with appearances, rather than flattening them

Coverage

This interface supplies independent query lists and occurrence metadata; general template/form node creation and cloning, additional node-class scripting, schema validation and external media remain separate work

XFA widget runtime ยท Native Data DOM