PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » XML » XML_Transformer » Manual

XML Transformations in PHP.

Introduction

Introduction – Introduction to XML_Transformer

Introduction to XML_Transformer

With the XML Transformer class one can easily bind PHP functionality to XML tags, thus transforming the input XML tree into an output XML tree without the need for XSLT. Single XML elements can be overloaded with PHP functions, methods and static method calls, XML namespaces can be registered to be handled by PHP classes.

XML_Transformer::XML_Transformer

XML_Transformer::XML_Transformer – Synopsis void XML_Transformer::XML_Transformer ( array parameters ) Description Constructor of the XML_Transformer class. It can be passed an associative array that may have the following keys: caseFolding: If TRUE, XML attribute and element names will be case-folded. caseFoldingTo: May be either CASE_UPPER or CASE_LOWER and sets the target case for the case-folding. debug: May be either TRUE or FALSE, thus enabling or disabling complete debugging information. May also be an array containing the names of elements to which the generated debugging information shall be limited. The special keywords "&CDATA" and "&RECURSE" may be used to enable debugging information for CDATA and recursion events. recursiveOperation: If TRUE, the transformation will continue recursively until the XML contains no more overloaded elements. Can be overrided on a per-element basis. overloadedElements: Associative array with pre-defined set of overloaded elements. overloadedNamespaces: Associative array with pre-defined set of overloaded elements.

XML_Transformer::overloadElement

XML_Transformer::overloadElement – Synopsis void XML_Transformer::overloadElement ( string element , string startHandler , string endHandler , boolean recursiveOperation ) Description Overloads an XML element and binds its opening and closing tags to a PHP callback. A PHP callback can be one of the following: A PHP Function. A PHP Method on an object. A static PHP Method. The optional fourth parameter can be used to override the global setting for recursive operation.

XML_Transformer::overloadNamespace

XML_Transformer::overloadNamespace – Synopsis void XML_Transformer::overloadNamespace ( string namespacePrefix , object object , boolean recursiveOperation ) Description Overloads an XML Namespace and binds all its elements to a PHP object, that must provide startElement($element, $attributes)() and endElement($element, $cdata)() methods. If the PHP object provides a initObserver($namespacePrefix, $transformer)() method it is automatically called with the registered namespace prefix and a reference to the XML_Transformer object.

XML_Transformer::isOverloadedElement

XML_Transformer::isOverloadedElement – Synopsis boolean XML_Transformer::isOverloadedElement ( string element ) Description Returns TRUE if the given element is overloaded, FALSE otherwise.

XML_Transformer::isOverloadedNamespace

XML_Transformer::isOverloadedNamespace – Synopsis boolean XML_Transformer::isOverloadedNamespace ( string namespacePrefix ) Description Returns TRUE if the given namespace is overloaded, FALSE otherwise.

XML_Transformer::unOverloadElement

XML_Transformer::unOverloadElement – Synopsis boolean XML_Transformer::unOverloadElement ( string element ) Description Reverts overloading of the given element.

XML_Transformer::unOverloadNamespace

XML_Transformer::unOverloadNamespace – Synopsis boolean XML_Transformer::unOverloadNamespace ( string namespacePrefix ) Description Reverts overloading of the given namespace.

XML_Transformer::start

XML_Transformer::start – Synopsis void XML_Transformer::start ( ) Description Starts the transformation, if it has not yet been started, for instance by the constructor.

XML_Transformer::transform

XML_Transformer::transform – Synopsis string XML_Transformer::transform ( string xml ) Description Transforms a given XML string.

XML_Transformer::setCaseFolding

XML_Transformer::setCaseFolding – Synopsis void XML_Transformer::setCaseFolding ( boolean caseFolding , integer caseFoldingTo ) Description Sets the XML parser's case-folding option.

XML_Transformer::setDebug

XML_Transformer::setDebug – Synopsis void XML_Transformer::setDebug ( mixed debug ) Description Enables or disables debugging to error.log. The parameter may be either TRUE or FALSE, thus enabling or disabling complete debugging information. May also be an array containing the names of elements to which the generated debugging information shall be limited. The special keywords "&CDATA" and "&RECURSE" may be used to enable debugging information for CDATA and recursion events.

XML_Transformer::setDebug

XML_Transformer::setDebug – Synopsis void XML_Transformer::setRecursiveOperation ( boolean recursiveOperation ) Description Enables or disables the recursive operation.

XML_Transformer::stackdump

XML_Transformer::stackdump – Synopsis string XML_Transformer::stackdump ( ) Description Returns a stack dump as a debugging aid.

XML_Transformer::attributesToString

XML_Transformer::attributesToString – Synopsis string XML_Transformer::attributesToString ( array attributes ) Description Returns string representation of attributes array.

XML_Transformer::canonicalize

XML_Transformer::canonicalize – Synopsis mixed XML_Transformer::canonicalName ( mixed target ) Description Canonicalizes XML attribute arrays and element names.