SetaPDF_FormFiller_Xfa_Bridge The helper class for processing XFA data and template data.

File: /SetaPDF v2/FormFiller/Xfa/Bridge.php

This class matches data nodes to template nodes and creates data nodes if they are not available.

The class actually only supports the default "mergeMode": "consumeData" mode.

So the logic for updating a field by its AcroForm name will be: - Check if a data node is already found for this specific field. - if not, start the data parsing process which mappes all find value nodes to specific fields if they don't have a bind-value. - direct matches have a higher priority than scope matches. - The process have to be done twice in case a direct match had overwritten a scope matched relation. - If the field still have no data node attached to it create a node (tree) for it and attach it. (only if the match attribute of the bind-value is not set to "none".) - Update the node if available.

Updating by changed XML data: - remove all bounded data nodes from all available fields - start the data parsing process and attach the nodes to the fields. - Iterate over all fields (XML) and set their values in their corresponding AcroForm fields. (omit recursivity)

TODO: - “Extended Mapping Rules” on page 508. (XFA Specification - 3.3) - XSLT Transformations (see page 545 - XFA Specification - 3.3) - Resolve mergeMode-attribute from root node (introduced in XFA 3.1, so maybee obsolete atm) - Handling of "picture" clauses (see page 156 / 1150 - XFA Specification - 3.3)

Class hierarchy




protected array SetaPDF_FormFiller_Xfa_Bridge::$_acroFormFieldNamesToTemplateNodes

A hash map for relation between a field node and its corresponding AcroForm representation.

The keys are the field names used in the AcroForm field. The value is the field node itself.


protected string SetaPDF_FormFiller_Xfa_Bridge::$_currentBinding

The current found binding from an accestor node.


protected integer SetaPDF_FormFiller_Xfa_Bridge::$_currentRootIndex

The current index of the data nodes in the data root element.


protected DOMElement SetaPDF_FormFiller_Xfa_Bridge::$_data

The data node.


protected SplObjectStorage SetaPDF_FormFiller_Xfa_Bridge::$_dataNodeByTemplateNode

The data node for a template node.


protected SplObjectStorage SetaPDF_FormFiller_Xfa_Bridge::$_dataPathByField

The default data path by a field node.


protected bool SetaPDF_FormFiller_Xfa_Bridge::$_dataProcessed = false

Flag indicating if the data were processed or not.


protected SplObjectStorage SetaPDF_FormFiller_Xfa_Bridge::$_dataRefBinding

The dataRef bindings of field nodes.


protected SplObjectStorage SetaPDF_FormFiller_Xfa_Bridge::$_fieldToFieldName

Fieldnames by field nodes.


protected SplObjectStorage SetaPDF_FormFiller_Xfa_Bridge::$_globalBinding

Global bindungs by field nodes.


protected SplObjectStorage SetaPDF_FormFiller_Xfa_Bridge::$_noneBinding

None bindings by field nodes.


protected DOMElement SetaPDF_FormFiller_Xfa_Bridge::$_template

The template node.



The constructor

$template : DOMElement
$data : DOMElement


protected SetaPDF_FormFiller_Xfa_Bridge::_bindDataNode (
array $path, DOMNode $dataNode, string $method [, boolean $allowOverwrite = true ]
): boolean

Tries to bind a data node to a field node.

Both "direct match" and "scope match" are evaluated.

$path : array
$dataNode : DOMNode
$method : string
$allowOverwrite : boolean


Creates of gets a data node by a field node.

$fieldNode : DOMElement


Tries to find a field node by a "direct match".

$path : array


private SetaPDF_FormFiller_Xfa_Bridge::_doScopeMatch (
array $path
): boolean|DOMElement

Tries to find a field node by a "scope match".

Example from the XFA specification:


Data: Jack Spratt 99 Candlestick Lane London UK SW1

$path : array


protected SetaPDF_FormFiller_Xfa_Bridge::_ensureDataValue (
array $fieldNodes, DOMNode $dataNode
): array

Ensure that the field node and data node match to each other.

This method filters the field nodes by the dataGroup attribute/property of the data node.

$fieldNodes : array
$dataNode : DOMNode


This method evaluates a data ref binding of a field node.

$fieldNode : DOMElement


This method evaluates a global binding, if exists, for a field node.

$fieldNode : DOMElement


private SetaPDF_FormFiller_Xfa_Bridge::_filtertBindings (
DOMElement|DOMElement[] $fieldNodes [, bool $isDirect = false ]
): array

This method filters field nodes which are already bound.

$fieldNodes : DOMElement|DOMElement[]
$isDirect : bool


protected SetaPDF_FormFiller_Xfa_Bridge::_isBind (
DOMNode $dataNode
): bool|DOMNode

Checks if a data node is already bound to a field node.

$dataNode : DOMNode


Parses the template and evaluates direct and global bindings.


protected SetaPDF_FormFiller_Xfa_Bridge::_processData (
DOMNode $node [, array $path = array ( ) [, array &$pathes = array ( ) [, string $method = 'direct' ]]]
): void

Processes the data and bind the nodes to the template/field nodes.

$node : DOMNode
$path : array
$pathes : array
$method : string


protected SetaPDF_FormFiller_Xfa_Bridge::_processDataAttributes (
DOMNode $node [, array $path = array ( ) [, array &$pathes = array ( ) [, string $method = 'direct' ]]]
): void

Process attributes to unbind tempalte/field nodes.

$node : DOMNode
$path : array
$pathes : array
$method : string


private SetaPDF_FormFiller_Xfa_Bridge::_processTemplate (
DOMNode $node [, array $path = array ( ) [, array &$dataPathCache = array ( ) [, string $currentDataPath = '' ]]]
): void

Processes a template node recursively.

This method resolves the field names representing the AcroForm fields in the PDF structure and ensures direct data pathes.

$node : DOMNode
$path : array
$dataPathCache : array
$currentDataPath : string


public SetaPDF_FormFiller_Xfa_Bridge::cleanUp (
): void

Release memory and cycled references.


Get all template nodes by their corresponding name used in the AcroForm representation.


public SetaPDF_FormFiller_Xfa_Bridge::getDataNodeByFieldName (
string $name [, boolean $create = true ]
): bool|DOMElement

Gets a data node by a field name.

This method returns the matching data node (DOMElement or DOMAttributeNode) object which is matched to the given field. If no data node is found it will create a new data node. If the field is defined to bind to nothing (match="none") the method will return false.

If an unknown fieldname is passed the method will throw an InvalidArgumentException exception.

$name : string
$create : boolean

Defines if a data node should be created if it cannot be found.


Throws InvalidArgumentException



public SetaPDF_FormFiller_Xfa_Bridge::getSameBoundFields (
string|DOMElement $fieldNode [, bool $asNames = false ]
): array|DOMElement[]

Get field names or nodes which are bound to the same data node.

$fieldNode : string|DOMElement
$asNames : bool

Defines wheter the method should return the names or field nodes.

Return Values

An array of field names or fields (DOMElements).


public SetaPDF_FormFiller_Xfa_Bridge::getTemplateNode (
string $fieldName
): bool|DOMElement

Get a fields node from the template packet.

$fieldName : string


public SetaPDF_FormFiller_Xfa_Bridge::isGlobalBinding (
): bool

Checks a field node for a global binding.