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
Summary
Methods
- __construct()
- _bindDataNode()
- _createDataNode()
- _doDirectMatch()
- _doScopeMatch()
- _ensureDataValue()
- _evaluateDataRefBindings()
- _evaluateGlobalBindings()
- _filtertBindings()
- _isBind()
- _parseTemplate()
- _processData()
- _processDataAttributes()
- _processTemplate()
- cleanUp()
- getAcroFormFieldNamesToTemplateNodes()
- getDataNodeByFieldName()
- getNoneBindingNodes()
- getSameBoundFields()
- getTemplateNode()
- getXPathsToFields()
- isGlobalBinding()
Properties
$_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.
$_currentBinding
The current found binding from an accestor node.
$_currentRootIndex
The current index of the data nodes in the data root element.
$_data
The data node.
$_form
The form node.
$_template
The template node.
$_xpathsToFields
A simple and direct XPath expression to field in either the template or form package.
Methods
__construct()
The constructor
Parameters
- $template : DOMElement
- $data : DOMElement
- $form : DOMElement
Exceptions
Throws SetaPDF_FormFiller_Exception
_bindDataNode()
Tries to bind a data node to a field node.
Both "direct match" and "scope match" are evaluated.
Parameters
- $path : array
- $dataNode : DOMNode
- $method : string
- $allowOverwrite : boolean
_createDataNode()
_doDirectMatch()
_doScopeMatch()
Tries to find a field node by a "scope match".
Example from the XFA specification:
Template:
<template …>
Data:
Parameters
- $path : array
Exceptions
Throws Exception
_ensureDataValue()
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.
Parameters
- $fieldNodes : array
- $dataNode : DOMNode
_evaluateDataRefBindings()
This method evaluates a data ref binding of a field node.
Parameters
- $fieldNode : DOMElement
Exceptions
Throws Exception
_evaluateGlobalBindings()
This method evaluates a global binding, if exists, for a field node.
Parameters
- $fieldNode : DOMElement
Exceptions
Throws Exception
_filtertBindings()
This method filters field nodes which are already bound.
Parameters
- $fieldNodes : DOMElement|DOMElement[]
- $isDirect : bool
_isBind()
_parseTemplate()
Parses the template and evaluates direct and global bindings.
Exceptions
Throws SetaPDF_FormFiller_Exception
_processData()
Processes the data and bind the nodes to the template/field nodes.
Parameters
- $node : DOMNode
- $path : array
- $pathes : array
- $method : string
_processDataAttributes()
Process attributes to unbind tempalte/field nodes.
Parameters
- $node : DOMNode
- $path : array
- $pathes : array
- $method : string
_processTemplate()
Processes a template node recursively.
This method resolves the field names representing the AcroForm fields in the PDF structure and ensures direct data pathes.
Parameters
- $node : DOMNode
- $nameParts : array
- $namePathCache : array
- $currentNamePath : string
- $dataPathCache : array
- $currentDataPath : string
- $xpathCache : array
- $currentXPath : string
Exceptions
Throws SetaPDF_FormFiller_Exception
getAcroFormFieldNamesToTemplateNodes()
Get all template nodes by their corresponding name used in the AcroForm representation.
getDataNodeByFieldName()
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.
Parameters
- $name : string
- $create : boolean
Defines if a data node should be created if it cannot be found.
Exceptions
Throws InvalidArgumentException
See
getSameBoundFields()
Get field names or nodes which are bound to the same data node.
Parameters
- $fieldNode : string|DOMElement
- $asNames : bool
Defines whether the method should return the names or field nodes.
Return Values
An array of field names or fields (\DOMElements).