blueshoes php application framework and cms            packageless
[ class tree: packageless ] [ index: packageless ] [ all elements ]

Class: XPathEngine

Source Location: /lib/XPath/XPath.class.php

Class Overview

XPathBase
   |
   --XPathEngine

**********************************************************************************************


Variables

Methods


Child classes:

XPath
**********************************************************************************************

Inherited Variables

Inherited Methods

Class: XPathBase

XPathBase::XPathBase()
Constructor
XPathBase::getLastError()
Returns the last occured error message.
XPathBase::reset()
Resets the object so it's able to take a new xml sting/file
XPathBase::setVerbose()
Alter the verbose (error) level reporting.
XPathBase::_afterstr()
Retrieves a substring after a delimiter.
XPathBase::_beginDebugFunction()
Called to begin the debug run of a function.
XPathBase::_bracketExplode()
Split a string by a searator-string -- BUT the separator-string must be located *outside* of any brackets.
XPathBase::_bracketsCheck()
This method checks the right amount and match of brackets
XPathBase::_closeDebugFunction()
Called to end the debug run of a function.
XPathBase::_displayError()
Displays an error message.
XPathBase::_displayMessage()
Displays a diagnostic message
XPathBase::_getEndGroups()
Split a string at it's groups, ie bracketed expressions
XPathBase::_prestr()
Retrieves a substring before a delimiter.
XPathBase::_printContext()
Echo an XPath context for diagnostic purposes
XPathBase::_profileFunction()
Call to return time since start of function for Profiling
XPathBase::_searchString()
Looks for a string within another string -- BUT the search-string must be located *outside* of any brackets.
XPathBase::_setLastError()
Creates a textual error message and sets it.
XPathBase::_treeDump()
This is a debug helper function. It dumps the node-tree as HTML

Class Details

[line 725]
**********************************************************************************************

=============================================================================================== X P a t h E n g i n e - Class =============================================================================================== **********************************************************************************************




[ Top ]


Class Variables

$axes = array ( 'ancestor', 'ancestor_or_self', 'attribute', 'child', 'descendant', 
                        'descendant_or_self', 'following', 'following_sibling',  
                        'namespace', 'parent', 'preceding', 'preceding_sibling', 'self' 
     )

[line 736]


Type:   mixed


[ Top ]

$axPathLiterals = array()

[line 767]


Type:   mixed


[ Top ]

$emptyNode = array(
                     'name'        => '',                            'attributes'  => array(),'childNodes'=>array(),'textParts'=>array(),'parentNode'=>NULL,'depth'=>0,'pos'=>0,'contextPos'=>1,'xpath'=>'')

[line 772]


Type:   mixed


[ Top ]

$errorStrings = array(
    'AbsoluteXPathRequired' => "The supplied xPath '%s' does not *uniquely* describe a node in the xml document.",
    'NoNodeMatch'           => "The supplied xPath-query '%s' does not match *any* node in the xml document.",
    'RootNodeAlreadyExists' => "An xml document may have only one root node."
    )

[line 798]


Type:   mixed


[ Top ]

$functions = array ( 'last', 'position', 'count', 'id', 'name',
    'string', 'concat', 'starts_with', 'contains', 'substring_before',
    'substring_after', 'substring', 'string_length', 'normalize_space', 'translate',
    'boolean', 'not', 'true', 'false', 'lang', 'number', 'sum', 'floor',
    'ceiling', 'round', 'x_lower', 'x_upper' )

[line 752]


Type:   mixed


[ Top ]

$nodeIndex = array()

[line 770]


Type:   mixed


[ Top ]

$nodeRoot = array()

[line 771]


Type:   mixed


[ Top ]

$nodeStack = array()

[line 788]


Type:   mixed


[ Top ]

$operators = array( ' or ', ' and ', '=', '!=', '<=', '<', '>=', '>',
    '+', '-', '*', ' div ', ' mod ', ' | ')

[line 763]


Type:   mixed


[ Top ]

$parsedTextLocation =  ''

[line 793]


Type:   mixed


[ Top ]

$parseOptions = array()

[line 792]


Type:   mixed


[ Top ]

$parseSkipWhiteCache =  0

[line 795]


Type:   mixed


[ Top ]

$parseStackIndex =  0

[line 789]


Type:   mixed


[ Top ]

$parsInCData =  0 

[line 794]


Type:   mixed


[ Top ]

$_indexIsDirty =  FALSE

[line 784]


Type:   mixed


[ Top ]



Class Methods


constructor XPathEngine [line 821]

XPathEngine XPathEngine( [$userXmlOptions $userXmlOptions = array()])

Constructor

Optionally you may call this constructor with the XML-filename to parse and the XML option vector. Each of the entries in the option vector will be passed to xml_parser_set_option().

A option vector sample: $xmlOpt = array(XML_OPTION_CASE_FOLDING => FALSE, XML_OPTION_SKIP_WHITE => TRUE);




Tags:



Parameters:

$userXmlOptions   $userXmlOptions   (array) (optional) Vector of (<optionID>=><value>, <optionID>=><value>, ...). See PHP's xml_parser_set_option() docu for a list of possible options.

[ Top ]

method cloneNode [line 2133]

(&array) &cloneNode( $node $node, [mixed $recursive = FALSE])

Clone a node and it's child nodes.

NOTE: If the node has children you *MUST* use the reference operator! E.g. $clonedNode =& cloneNode($node); Otherwise the children will not point back to the parent, they will point back to your temporary variable instead.




Tags:

return:  A node and it's child nodes.


Parameters:

$node   $node   (mixed) Either a node (hash array) or an abs. Xpath to a node in the current doc

[ Top ]

method decodeEntities [line 4358]

(mixed) decodeEntities( $encodedData $encodedData, [$reverse $reverse = FALSE])

Decodes the character set entities in the given string.

This function is given for convenience, as all text strings or attributes are going to come back to you with their entities still encoded. You can use this function to remove these entites.

It makes use of the get_html_translation_table(HTML_ENTITIES) php library call, so is limited in the same ways. At the time of writing this seemed be restricted to iso-8859-1

### Provide an option that will do this by default.




Tags:

return:  The string or array returned with entities decoded.


Parameters:

$encodedData   $encodedData   (mixed) The string or array that has entities you would like to remove
$reverse   $reverse   (bool) If TRUE entities will be encoded rather than decoded, ie < to &lt; rather than &lt; to <.

[ Top ]

method equalNodes [line 4398]

(bool) equalNodes( $node1 $node1, $node2 $node2)

Compare two nodes to see if they are equal (point to the same node in the doc)

2 nodes are considered equal if the absolute XPath is equal.




Tags:

return:  TRUE if equal (see text above), FALSE if not (and on error).


Parameters:

$node1   $node1   (mixed) Either an absolute XPath to an node OR a real tree-node (hash-array)
$node2   $node2   (mixed) Either an absolute XPath to an node OR a real tree-node (hash-array)

[ Top ]

method evaluate [line 2271]

void evaluate( mixed $xPathQuery, [mixed $baseXPath = ''])

Alias for the match function



Tags:



[ Top ]

method exportAsHtml [line 1078]

(mixed) exportAsHtml( [$absoluteXPath $absoluteXPath = ''], [$hilighXpathList $hilightXpathList = array()])

Returns the containing XML as marked up HTML with specified nodes hi-lighted



Tags:

return:  The Xml document marked up as HTML so that it can be viewed in a browser, including any XML headers. FALSE on error.
see:  XPathEngine::_export()


Parameters:

$absoluteXPath   $absoluteXPath   (string) The address of the node you would like to export. If empty the whole document will be exported.
$hilighXpathList   $hilightXpathList   (array) A list of nodes that you would like to highlight

[ Top ]

method exportAsXml [line 1098]

(mixed) exportAsXml( [$absoluteXPath $absoluteXPath = ''], [$xmlHeader $xmlHeader = NULL])

Given a context this function returns the containing XML



Tags:

return:  The Xml fragment/document, suitable for writing out to an .xml file or as part of a larger xml file, or FALSE on error.
see:  XPathEngine::_export()


Parameters:

$absoluteXPath   $absoluteXPath   (string) The address of the node you would like to export. If empty the whole document will be exported.
$xmlHeader   $xmlHeader   (array) The string that you would like to appear before the XML content. ie before the <root></root>. If you do not specify this argument, the xmlHeader that was found in the parsed xml file will be used instead.

[ Top ]

method exportToFile [line 1118]

(string) exportToFile( $fileName $fileName, [$absoluteXPath $absoluteXPath = ''], [$xmlHeader $xmlHeader = NULL])

Generates a XML string with the content of the current document and writes it to a file.

Per default includes a <?xml ...> tag at the start of the data too.




Tags:

return:  The returned string contains well-formed XML data or FALSE on error.
see:  XPathEngine::exportAsXml(), XPathEngine::exportAsHtml()


Parameters:

$fileName   $fileName   (string)
$absoluteXPath   $absoluteXPath   (string) The path to the parent node you want(see text above)
$xmlHeader   $xmlHeader   (array) The string that you would like to appear before the XML content. ie before the <root></root>. If you do not specify this argument, the xmlHeader that was found in the parsed xml file will be used instead.

[ Top ]

method getNode [line 950]

(array) &getNode( [$absoluteXPath $absoluteXPath = ''])

Get the node defined by the $absoluteXPath.



Tags:

return:  The node, or FALSE if the node wasn't found.


Parameters:

$absoluteXPath   $absoluteXPath   (string) (optional, default is 'super-root') xpath to the node.

[ Top ]

method getNodePath [line 4410]

(string) getNodePath( $node $node)

Get the absolute XPath of a node that is in a document tree.



Tags:

return:  The string path to the node or FALSE on error.


Parameters:

$node   $node   (array) A real tree-node (hash-array)

[ Top ]

method getParentXPath [line 4437]

(string) getParentXPath( $childPath $absoluteXPath)

Retrieves the absolute parent XPath query.

The parents stored in the tree are only relative parents...but all the parent information is stored in the XPath query itself...so instead we use a function to extract the parent from the absolute Xpath query




Tags:

return:  returns the absolute XPath of the parent


Parameters:

$childPath   $absoluteXPath   (string) String containing an absolute XPath query

[ Top ]

method getProperties [line 867]

(mixed) getProperties( [$param $param = NULL])

Returns the property/ies you want.

if $param is not given, all properties will be returned in a hash.




Tags:

return:  string OR hash of all params, or NULL on an unknown parameter.


Parameters:

$param   $param   (string) the property you want the value of, or NULL for all the properties

[ Top ]

method hasChildNodes [line 4452]

(bool) hasChildNodes( $absoluteXPath $absoluteXPath)

Returns TRUE if the given node has child nodes below it



Tags:

return:  TRUE if this node exists and has a child, FALSE otherwise


Parameters:

$absoluteXPath   $absoluteXPath   (string) full path of the potential parent node

[ Top ]

method importFromFile [line 1513]

(bool) importFromFile( $fileName $fileName)

Reads a file or URL and parses the XML data.

Parse the XML source and (upon success) store the information into an internal structure.




Tags:

return:  TRUE on success, FALSE on failure (check getLastError())
see:  XPathEngine::importFromString(), XPathBase::getLastError(),


Parameters:

$fileName   $fileName   (string) Path and name (or URL) of the file to be read and parsed.

[ Top ]

method importFromString [line 1578]

(bool) importFromString( $xmlString $xmlString, [$absoluteParentPath $absoluteParentPath = ''])

Reads a string and parses the XML data.

Parse the XML source and (upon success) store the information into an internal structure. If a parent xpath is given this means that XML data is to be *appended* to that parent.

### If a function uses setLastError(), then say in the function header that getLastError() is useful.




Tags:

return:  TRUE on success, FALSE on failure (check getLastError())


Parameters:

$xmlString   $xmlString   (string) Name of the string to be read and parsed.
$absoluteParentPath   $absoluteParentPath   (string) Node to append data too (see above)

[ Top ]

method match [line 2208]

(mixed) match( $xPathQuery $xPathQuery, [$baseXPath $baseXPath = ''])

Matches (evaluates) an XPath query

This method tries to evaluate an XPath query by parsing it. A XML source must have been imported before this method is able to work.




Tags:

return:  The result of the XPath expression. Either: node-set (an ordered collection of absolute references to nodes without duplicates) boolean (true or false) number (a floating-point number) string (a sequence of UCS characters)


Parameters:

$xPathQuery   $xPathQuery   (string) XPath query to be evaluated.
$baseXPath   $baseXPath   (string) (default is super-root) XPath query to a single document node, from which the XPath query should start evaluating.

[ Top ]

method reindexNodeTree [line 2023]

(bool) reindexNodeTree( )

Update nodeIndex and every node of the node-tree.

Call after you have finished any tree modifications other wise a match with an xPathQuery will produce wrong results. The $this->nodeIndex[] is recreated and every nodes optimization data is updated. The optimization data is all the data that is duplicate information, would just take longer to find. Child nodes with value NULL are removed from the tree.

By default the modification functions in this component will automatically re-index the nodes in the tree. Sometimes this is not the behaver you want. To surpress the reindex, set the functions $autoReindex to FALSE and call reindexNodeTree() at the end of your changes. This sometimes leads to better code (and less CPU overhead).

Sample: ======= Given the xml is <AAA><B/>.<B/>.<B/></AAA> | Goal is <AAA>.<B/>.</AAA> (Delete B[1] and B[3]) $xPathSet = $xPath->match('//B'); # Will result in array('/AAA[1]/B[1]', '/AAA[1]/B[2]', '/AAA[1]/B[3]'); Three ways to do it. 1) Top-Down (with auto reindexing) - Safe, Slow and you get easily mix up with the the changing node index removeChild('/AAA[1]/B[1]'); // B[1] removed, thus all B[n] become B[n-1] !! removeChild('/AAA[1]/B[2]'); // Now remove B[2] (That originaly was B[3]) 2) Bottom-Up (with auto reindexing) - Safe, Slow and the changing node index (caused by auto-reindex) can be ignored. for ($i=sizeOf($xPathSet)-1; $i>=0; $i--) { if ($i==1) continue; removeChild($xPathSet[$i]); } 3) // Top-down (with *NO* auto reindexing) - Fast, Safe as long as you call reindexNodeTree() foreach($xPathSet as $xPath) { // Specify no reindexing if ($xPath == $xPathSet[1]) continue; removeChild($xPath, $autoReindex=FALSE); // The object is now in a slightly inconsistent state. } // Finally do the reindex and the object is consistent again reindexNodeTree();




Tags:

return:  TRUE on success, FALSE otherwise.
see:  XPathEngine::_recursiveReindexNodeTree()


[ Top ]

method reset [line 841]

void reset( )

Resets the object so it's able to take a new xml sting/file

Constructing objects is slow. If you can, reuse ones that you have used already by using this reset() function.




Overridden in child classes as:

XPath::reset()
Resets the object so it's able to take a new xml sting/file

Overrides XPathBase::reset() (Resets the object so it's able to take a new xml sting/file)

[ Top ]

method setCaseFolding [line 919]

void setCaseFolding( [$onOff $onOff = TRUE])

Alternative way to control whether case-folding is enabled for this XML parser.

Short cut to setXmlOptions(XML_OPTION_CASE_FOLDING, TRUE/FALSE)

When it comes to XML, case-folding simply means uppercasing all tag- and attribute-names (NOT the content) if set to TRUE. Note if you have this option set, then your XPath queries will also be case folded for you.




Tags:

see:  XML parser functions in PHP doc


Parameters:

$onOff   $onOff   (bool) (default TRUE)

[ Top ]

method setSkipWhiteSpaces [line 940]

void setSkipWhiteSpaces( [$onOff $onOff = TRUE])

Alternative way to control whether skip-white-spaces is enabled for this XML parser.

Short cut to setXmlOptions(XML_OPTION_SKIP_WHITE, TRUE/FALSE)

When it comes to XML, skip-white-spaces will trim the tag content. An XML file with no whitespace will be faster to process, but will make your data less human readable when you come to write it out.

Running with this option on will slow the class down, so if you want to speed up your XML, then run it through once skipping white-spaces, then write out the new version of your XML without whitespace, then use the new XML file with skip whitespaces turned off.




Tags:

see:  XML parser functions in PHP doc


Parameters:

$onOff   $onOff   (bool) (default TRUE)

[ Top ]

method setXmlOption [line 888]

void setXmlOption( $optionID $optionID, $value $value)

Set an xml_parser_set_option()



Tags:

see:  XML parser functions in PHP doc


Parameters:

$optionID   $optionID   (int) The option ID (e.g. XML_OPTION_SKIP_WHITE)
$value   $value   (int) The option value.

[ Top ]

method setXmlOptions [line 899]

void setXmlOptions( [$userXmlOptions $userXmlOptions = array()])

Sets a number of xml_parser_set_option()s



Tags:



Parameters:

$userXmlOptions   $userXmlOptions   (array) An array of parser options.

[ Top ]

method wholeText [line 986]

(&string) &wholeText( $absoluteXPath $absoluteXPath, [$textPartNr $textPartNr = NULL])

Get a the content of a node text part or node attribute.

If the absolute Xpath references an attribute (Xpath ends with @ or attribute::), then the text value of that node-attribute is returned. Otherwise the Xpath is referencing a text part of the node. This can be either a direct reference to a text part (Xpath ends with text()[<nr>]) or indirect reference (a simple abs. Xpath to a node). 1) Direct Reference (xpath ends with text()[<part-number>]): If the 'part-number' is omitted, the first text-part is assumed; starting by 1. Negative numbers are allowed, where -1 is the last text-part a.s.o. 2) Indirect Reference (a simple abs. Xpath to a node): Default is to return the *whole text*; that is the concated text-parts of the matching node. (NOTE that only in this case you'll only get a copy and changes to the returned value wounld have no effect). Optionally you may pass a parameter $textPartNr to define the text-part you want; starting by 1. Negative numbers are allowed, where -1 is the last text-part a.s.o.

NOTE I : The returned value can be fetched by reference E.g. $text =& wholeText(). If you wish to modify the text. NOTE II: text-part numbers out of range will return FALSE SIDENOTE:The function name is a suggestion from W3C in the XPath specification level 3.




Tags:

return:  A *reference* to the text if the node that the other parameters describe or FALSE if the node is not found.


Parameters:

$absoluteXPath   $absoluteXPath   (string) xpath to the node (See above).
$textPartNr   $textPartNr   (int) If referring to a node, specifies which text part to query.

[ Top ]

method _addLiteral [line 2360]

(mixed) _addLiteral( $string $string)

Adds a literal to our array of literals

In order to make sure we don't interpret literal strings as XPath expressions, we have to encode literal strings so that we know that they are not XPaths.




Tags:

return:  A reference string to this literal.


Parameters:

$string   $string   (string) The literal string that we need to store for future access

[ Top ]

method _asLiteral [line 2331]

(mixed) _asLiteral( $string $string)

Returns the given string as a literal reference.



Tags:

return:  The literal string. FALSE if the string isn't a literal reference.


Parameters:

$string   $string   (string) The string that we are processing

[ Top ]

method _checkNodeTest [line 3213]

(boolean) _checkNodeTest( $contextPath $contextPath, $nodeTest $nodeTest)

Checks whether a node matches a node-test.

This method checks whether a node in the document matches a given node-test. A node test is something like text(), node(), or an element name.




Tags:

return:  This method returns TRUE if the node matches the node-test, otherwise FALSE.
see:  XPathEngine::evaluate()


Parameters:

$contextPath   $contextPath   (string) Full xpath of the node, which should be tested for matching the node-test.
$nodeTest   $nodeTest   (string) String containing the node-test for the node.

[ Top ]

method _checkPredicates [line 3059]

(array) _checkPredicates( $xPathSet $xPathSet, $predicates $predicates)

Checks whether a node matches predicates.

This method checks whether a list of nodes passed to this method match a given list of predicates.




Tags:

return:  Vector of absolute XPath's that match the given predicates.
see:  XPathEngine::_evaluateStep()


Parameters:

$xPathSet   $xPathSet   (array) Array of full paths of all nodes to be tested.
$predicates   $predicates   (array) Array of predicates to use.

[ Top ]

method _createSuperRoot [line 1901]

void _createSuperRoot( )

Creates a super root node.



[ Top ]

method _evaluateExpr [line 2387]

(mixed) _evaluateExpr( $xPathQuery $xPathQuery, $context $context)

Internal recursive evaluate an-XPath-expression function.

$this->evaluate() is the entry point and does some inits, while this function is called recursive internaly for every sub-xPath expresion we find.




Tags:

return:  The result of the XPath expression. Either: node-set (an ordered collection of nodes without duplicates) boolean (true or false) number (a floating-point number) string (a sequence of UCS characters)
see:  XPathEngine::evaluate()


Parameters:

$xPathQuery   $xPathQuery   (string) XPath query to be evaluated.
$context   $context   (array) An associative array the describes the context from which to evaluate the XPath Expr. Contains three members: 'nodePath' => The absolute XPath expression to the context node 'size' => The context size 'pos' => The context position

[ Top ]

method _evaluateFunction [line 3155]

(mixed) _evaluateFunction( $function $function, $arguments $arguments, $context $context)

Evaluates an XPath function

This method evaluates a given XPath function with its arguments on a specific node of the document.




Tags:

return:  This method returns the result of the evaluation of the function. Depending on the function the type of the return value can be different.
see:  XPathEngine::evaluate()


Parameters:

$function   $function   (string) Name of the function to be evaluated.
$arguments   $arguments   (string) String containing the arguments being passed to the function.
$context   $context   (array) The context from which to evaluate

[ Top ]

method _evaluatePathExpr [line 2806]

(mixed) _evaluatePathExpr( $PathExpr $PathExpr, $context $context)

Internal recursive evaluate an Path expression.



Tags:

return:  The result of the XPath expression. Either: node-set (an ordered collection of nodes without duplicates) boolean (true or false) number (a floating-point number) string (a sequence of UCS characters)
see:  XPathEngine::evaluate()


Parameters:

$PathExpr   $PathExpr   (string) PathExpr syntactical element
$context   $context   (array) The context from which to evaluate

[ Top ]

method _evaluateStep [line 2962]

(array) _evaluateStep( $steps $steps, $context $context)

Evaluate a step from a XPathQuery expression at a specific contextPath.

Steps are the arguments of a XPathQuery when divided by a '/'. A contextPath is a absolute XPath (or vector of XPaths) to a starting node(s) from which the step should be evaluated.




Tags:

return:  Vector of absolute XPath's as a result of the step evaluation. The results will not necessarily be in doc order
see:  XPathEngine::evaluate()


Parameters:

$steps   $steps   (array) Vector containing the remaining steps of the current XPathQuery expression.
$context   $context   (array) The context from which to evaluate

[ Top ]

method _export [line 1188]

(mixed) _export( [$absoluteXPath $absoluteXPath = ''], [$xmlHeader $xmlHeader = NULL], [$hilightXpath $hilightXpathList = ''])

Generates a XML string with the content of the current document.

This is the start for extracting the XML-data from the node-tree. We do some preperations and then call _InternalExport() to fetch the main XML-data. You optionally may pass xpath to any node that will then be used as top node, to extract XML-parts of the document. Default is '', meaning to extract the whole document.

You also may pass a 'xmlHeader' (usually something like <?xml version="1.0"? > that will overwrite any other 'xmlHeader', if there was one in the original source. If there wasn't one in the original source, and you still don't specify one, then it will use a default of <?xml version="1.0"? > Finaly, when exporting to HTML, you may pass a vector xPaths you want to hi-light. The hi-lighted tags and attributes will receive a nice color.

NOTE I : The output can have 2 formats: a) If "skip white spaces" is/was set. (Not Recommended - slower) The output is formatted by adding indenting and carriage returns. b) If "skip white spaces" is/was *NOT* set. 'as is'. No formatting is done. The output should the same as the the original parsed XML source.




Tags:

return:  The xml string, or FALSE on error.


Parameters:

$absoluteXPath   $absoluteXPath   (string) (optional, default is root) The node we choose as top-node
$xmlHeader   $xmlHeader   (string) (optional) content before <root/> (see text above)
$hilightXpath   $hilightXpathList   (array) (optional) a vector of xPaths to nodes we wat to hi-light (see text above)

[ Top ]

method _getAxis [line 3287]

(array) _getAxis( $step $step, $context $context)

Retrieves axis information from an XPath query step.

This method tries to extract the name of the axis and its node-test from a given step of an XPath query at a given node.




Tags:

return:  Contains information about the axis found in the step.
see:  XPathEngine::_evaluateStep()


Parameters:

$step   $step   (string) String containing a step of an XPath query.
$context   $context   (array) The context from which to evaluate

[ Top ]

method _handleAxis_ancestor [line 3564]

(array) _handleAxis_ancestor( $axis $axis, $contextPath $contextPath)

Handles the XPath ancestor axis.



Tags:

return:  A vector containing all nodes that were found, during the evaluation of the axis.
see:  XPathEngine::evaluate()


Parameters:

$axis   $axis   (array) Array containing information about the axis.
$contextPath   $contextPath   (string) xpath to starting node from which the axis should be processed.

[ Top ]

method _handleAxis_ancestor_or_self [line 3753]

(array) _handleAxis_ancestor_or_self( $axis $axis, $contextPath $contextPath)

Handles the XPath ancestor-or-self axis.

This method handles the XPath ancestor-or-self axis.




Tags:

return:  A vector containing all nodes that were found, during the evaluation of the axis.
see:  XPathEngine::evaluate()


Parameters:

$axis   $axis   (array) Array containing information about the axis.
$contextPath   $contextPath   (string) xpath to starting node from which the axis should be processed.

[ Top ]

method _handleAxis_attribute [line 3493]

(array) _handleAxis_attribute( $axis $axis, $contextPath $contextPath)

Handles the XPath attribute axis.



Tags:

return:  A vector containing all nodes that were found, during the evaluation of the axis.
see:  XPathEngine::evaluate()


Parameters:

$axis   $axis   (array) Array containing information about the axis.
$contextPath   $contextPath   (string) xpath to starting node from which the axis should be processed.

[ Top ]

method _handleAxis_child [line 3427]

(array) _handleAxis_child( $axis $axis, $contextPath $contextPath)

Handles the XPath child axis.

This method handles the XPath child axis. It essentially filters out the children to match the name specified after the '/'.




Tags:

return:  A vector containing all nodes that were found, during the evaluation of the axis.
see:  XPathEngine::evaluate()


Parameters:

$axis   $axis   (array) Array containing information about the axis.
$contextPath   $contextPath   (string) xpath to starting node from which the axis should be processed.

[ Top ]

method _handleAxis_descendant [line 3536]

(array) _handleAxis_descendant( $axis $axis, $contextPath $contextPath)

Handles the XPath descendant axis.



Tags:

return:  A vector containing all nodes that were found, during the evaluation of the axis.
see:  XPathEngine::evaluate()


Parameters:

$axis   $axis   (array) Array containing information about the axis.
$contextPath   $contextPath   (string) xpath to starting node from which the axis should be processed.

[ Top ]

method _handleAxis_descendant_or_self [line 3732]

(array) _handleAxis_descendant_or_self( $axis $axis, $contextPath $contextPath)

Handles the XPath descendant-or-self axis.



Tags:

return:  A vector containing all nodes that were found, during the evaluation of the axis.
see:  XPathEngine::evaluate()


Parameters:

$axis   $axis   (array) Array containing information about the axis.
$contextPath   $contextPath   (string) xpath to starting node from which the axis should be processed.

[ Top ]

method _handleAxis_following [line 3601]

(array) _handleAxis_following( $axis $axis, $contextPath $contextPath)

Handles the XPath following axis.



Tags:

return:  A vector containing all nodes that were found, during the evaluation of the axis.
see:  XPathEngine::evaluate()


Parameters:

$axis   $axis   (array) Array containing information about the axis.
$contextPath   $contextPath   (string) xpath to starting node from which the axis should be processed.

[ Top ]

method _handleAxis_following_sibling [line 3666]

(array) _handleAxis_following_sibling( $axis $axis, $contextPath $contextPath)

Handles the XPath following-sibling axis.



Tags:

return:  A vector containing all nodes that were found, during the evaluation of the axis.
see:  XPathEngine::evaluate()


Parameters:

$axis   $axis   (array) Array containing information about the axis.
$contextPath   $contextPath   (string) xpath to starting node from which the axis should be processed.

[ Top ]

method _handleAxis_namespace [line 3589]

(array) _handleAxis_namespace( $axis $axis, $contextPath $contextPath)

Handles the XPath namespace axis.



Tags:

return:  A vector containing all nodes that were found, during the evaluation of the axis.
see:  XPathEngine::evaluate()


Parameters:

$axis   $axis   (array) Array containing information about the axis.
$contextPath   $contextPath   (string) xpath to starting node from which the axis should be processed.

[ Top ]

method _handleAxis_parent [line 3474]

(array) _handleAxis_parent( $axis $axis, $contextPath $contextPath)

Handles the XPath parent axis.



Tags:

return:  A vector containing all nodes that were found, during the evaluation of the axis.
see:  XPathEngine::evaluate()


Parameters:

$axis   $axis   (array) Array containing information about the axis.
$contextPath   $contextPath   (string) xpath to starting node from which the axis should be processed.

[ Top ]

method _handleAxis_preceding [line 3636]

(array) _handleAxis_preceding( $axis $axis, $contextPath $contextPath)

Handles the XPath preceding axis.



Tags:

return:  A vector containing all nodes that were found, during the evaluation of the axis.
see:  XPathEngine::evaluate()


Parameters:

$axis   $axis   (array) Array containing information about the axis.
$contextPath   $contextPath   (string) xpath to starting node from which the axis should be processed.

[ Top ]

method _handleAxis_preceding_sibling [line 3702]

(array) _handleAxis_preceding_sibling( $axis $axis, $contextPath $contextPath)

Handles the XPath preceding-sibling axis.



Tags:

return:  A vector containing all nodes that were found, during the evaluation of the axis.
see:  XPathEngine::evaluate()


Parameters:

$axis   $axis   (array) Array containing information about the axis.
$contextPath   $contextPath   (string) xpath to starting node from which the axis should be processed.

[ Top ]

method _handleAxis_self [line 3518]

(array) _handleAxis_self( $axis $axis, $contextPath $contextPath)

Handles the XPath self axis.



Tags:

return:  A vector containing all nodes that were found, during the evaluation of the axis.
see:  XPathEngine::evaluate()


Parameters:

$axis   $axis   (array) Array containing information about the axis.
$contextPath   $contextPath   (string) xpath to starting node from which the axis should be processed.

[ Top ]

method _handleCharacterData [line 1826]

void _handleCharacterData( $parser $parser, $text $text)

Handles character data while parsing.

While parsing a XML document for each character data this method is called. It'll add the character data to the document tree.




Tags:



Parameters:

$parser   $parser   (int) Handler for accessing the current XML parser.
$text   $text   (string) Character data found in the document.

[ Top ]

method _handleDefaultData [line 1859]

void _handleDefaultData( $parser $parser, $text $text)

Default handler for the XML parser.

While parsing a XML document for string not caught by one of the other handler functions, we end up here.




Tags:



Parameters:

$parser   $parser   (int) Handler for accessing the current XML parser.
$text   $text   (string) Character data found in the document.

[ Top ]

method _handleEndElement [line 1776]

void _handleEndElement( $parser $parser, $name $name)

Handles closing XML tags while parsing.

While parsing a XML document for each closing tag this method is called.




Tags:



Parameters:

$parser   $parser   (int) Handler for accessing the current XML parser.
$name   $name   (string) Name of the closing tag found in the document.

[ Top ]

method _handleFunction_boolean [line 4092]

(mixed) _handleFunction_boolean( $arguments $arguments, $context $context)

Handles the XPath function boolean.



Tags:

return:  Depending on the type of function being processed
see:  XPathEngine::evaluate()


Parameters:

$arguments   $arguments   (string) String containing the arguments that were passed to the function.
$context   $context   (array) The context from which to evaluate the function

[ Top ]

method _handleFunction_ceiling [line 4272]

(mixed) _handleFunction_ceiling( $arguments $arguments, $context $context)

Handles the XPath function ceiling.



Tags:

return:  Depending on the type of function being processed
see:  XPathEngine::evaluate()


Parameters:

$arguments   $arguments   (string) String containing the arguments that were passed to the function.
$context   $context   (array) The context from which to evaluate the function

[ Top ]

method _handleFunction_concat [line 3901]

(mixed) _handleFunction_concat( $arguments $arguments, $context $context)

Handles the XPath function concat.



Tags:

return:  Depending on the type of function being processed
see:  XPathEngine::evaluate()


Parameters:

$arguments   $arguments   (string) String containing the arguments that were passed to the function.
$context   $context   (array) The context from which to evaluate the function

[ Top ]

method _handleFunction_contains [line 3942]

(mixed) _handleFunction_contains( $arguments $arguments, $context $context)

Handles the XPath function contains.



Tags:

return:  Depending on the type of function being processed
see:  XPathEngine::evaluate()


Parameters:

$arguments   $arguments   (string) String containing the arguments that were passed to the function.
$context   $context   (array) The context from which to evaluate the function

[ Top ]

method _handleFunction_count [line 3801]

(mixed) _handleFunction_count( $arguments $arguments, $context $context)

Handles the XPath function count.



Tags:

return:  Depending on the type of function being processed
see:  XPathEngine::evaluate()


Parameters:

$arguments   $arguments   (string) String containing the arguments that were passed to the function.
$context   $context   (array) The context from which to evaluate the function

[ Top ]

method _handleFunction_false [line 4164]

(mixed) _handleFunction_false( $arguments $arguments, $context $context)

Handles the XPath function FALSE.



Tags:

return:  Depending on the type of function being processed
see:  XPathEngine::evaluate()


Parameters:

$arguments   $arguments   (string) String containing the arguments that were passed to the function.
$context   $context   (array) The context from which to evaluate the function

[ Top ]

method _handleFunction_floor [line 4256]

(mixed) _handleFunction_floor( $arguments $arguments, $context $context)

Handles the XPath function floor.



Tags:

return:  Depending on the type of function being processed
see:  XPathEngine::evaluate()


Parameters:

$arguments   $arguments   (string) String containing the arguments that were passed to the function.
$context   $context   (array) The context from which to evaluate the function

[ Top ]

method _handleFunction_id [line 3814]

(mixed) _handleFunction_id( $arguments $arguments, $context $context)

Handles the XPath function id.



Tags:

return:  Depending on the type of function being processed
see:  XPathEngine::evaluate()


Parameters:

$arguments   $arguments   (string) String containing the arguments that were passed to the function.
$context   $context   (array) The context from which to evaluate the function

[ Top ]

method _handleFunction_lang [line 4176]

(mixed) _handleFunction_lang( $arguments $arguments, $context $context)

Handles the XPath function lang.



Tags:

return:  Depending on the type of function being processed
see:  XPathEngine::evaluate()


Parameters:

$arguments   $arguments   (string) String containing the arguments that were passed to the function.
$context   $context   (array) The context from which to evaluate the function

[ Top ]

method _handleFunction_last [line 3777]

(mixed) _handleFunction_last( $arguments $arguments, $context $context)

Handles the XPath function last.



Tags:

return:  Depending on the type of function being processed
see:  XPathEngine::evaluate()


Parameters:

$arguments   $arguments   (string) String containing the arguments that were passed to the function.
$context   $context   (array) The context from which to evaluate the function

[ Top ]

method _handleFunction_name [line 3839]

(mixed) _handleFunction_name( $arguments $arguments, $context $context)

Handles the XPath function name.



Tags:

return:  Depending on the type of function being processed
see:  XPathEngine::evaluate()


Parameters:

$arguments   $arguments   (string) String containing the arguments that were passed to the function.
$context   $context   (array) The context from which to evaluate the function

[ Top ]

method _handleFunction_normalize_space [line 4054]

(stri)g _handleFunction_normalize_space( $arguments $arguments, $context $context)

Handles the XPath function normalize-space.

The normalize-space function returns the argument string with whitespace normalized by stripping leading and trailing whitespace and replacing sequences of whitespace characters by a single space. If the argument is omitted, it defaults to the context node converted to a string, in other words the string-value of the context node




Tags:

return:  trimed string
see:  XPathEngine::evaluate()


Parameters:

$arguments   $arguments   (string) String containing the arguments that were passed to the function.
$context   $context   (array) The context from which to evaluate the function

[ Top ]

method _handleFunction_not [line 4137]

(mixed) _handleFunction_not( $arguments $arguments, $context $context)

Handles the XPath function not.



Tags:

return:  Depending on the type of function being processed
see:  XPathEngine::evaluate()


Parameters:

$arguments   $arguments   (string) String containing the arguments that were passed to the function.
$context   $context   (array) The context from which to evaluate the function

[ Top ]

method _handleFunction_number [line 4198]

(mixed) _handleFunction_number( $arguments $arguments, $context $context)

Handles the XPath function number.



Tags:

return:  Depending on the type of function being processed
see:  XPathEngine::evaluate()


Parameters:

$arguments   $arguments   (string) String containing the arguments that were passed to the function.
$context   $context   (array) The context from which to evaluate the function

[ Top ]

method _handleFunction_position [line 3789]

(mixed) _handleFunction_position( $arguments $arguments, $context $context)

Handles the XPath function position.



Tags:

return:  Depending on the type of function being processed
see:  XPathEngine::evaluate()


Parameters:

$arguments   $arguments   (string) String containing the arguments that were passed to the function.
$context   $context   (array) The context from which to evaluate the function

[ Top ]

method _handleFunction_round [line 4288]

(mixed) _handleFunction_round( $arguments $arguments, $context $context)

Handles the XPath function round.



Tags:

return:  Depending on the type of function being processed
see:  XPathEngine::evaluate()


Parameters:

$arguments   $arguments   (string) String containing the arguments that were passed to the function.
$context   $context   (array) The context from which to evaluate the function

[ Top ]

method _handleFunction_starts_with [line 3923]

(mixed) _handleFunction_starts_with( $arguments $arguments, $context $context)

Handles the XPath function starts-with.



Tags:

return:  Depending on the type of function being processed
see:  XPathEngine::evaluate()


Parameters:

$arguments   $arguments   (string) String containing the arguments that were passed to the function.
$context   $context   (array) The context from which to evaluate the function

[ Top ]

method _handleFunction_string [line 3862]

(mixed) _handleFunction_string( $arguments $arguments, $context $context)

Handles the XPath function string.



Tags:

return:  Depending on the type of function being processed
see:  XPathEngine::evaluate()


Parameters:

$arguments   $arguments   (string) String containing the arguments that were passed to the function.
$context   $context   (array) The context from which to evaluate the function

[ Top ]

method _handleFunction_string_length [line 4033]

(mixed) _handleFunction_string_length( $arguments $arguments, $context $context)

Handles the XPath function string-length.



Tags:

return:  Depending on the type of function being processed
see:  XPathEngine::evaluate()


Parameters:

$arguments   $arguments   (string) String containing the arguments that were passed to the function.
$context   $context   (array) The context from which to evaluate the function

[ Top ]

method _handleFunction_substring [line 4008]

(mixed) _handleFunction_substring( $arguments $arguments, $context $context)

Handles the XPath function substring.



Tags:

return:  Depending on the type of function being processed
see:  XPathEngine::evaluate()


Parameters:

$arguments   $arguments   (string) String containing the arguments that were passed to the function.
$context   $context   (array) The context from which to evaluate the function

[ Top ]

method _handleFunction_substring_after [line 3989]

(mixed) _handleFunction_substring_after( $arguments $arguments, $context $context)

Handles the XPath function substring-after.



Tags:

return:  Depending on the type of function being processed
see:  XPathEngine::evaluate()


Parameters:

$arguments   $arguments   (string) String containing the arguments that were passed to the function.
$context   $context   (array) The context from which to evaluate the function

[ Top ]

method _handleFunction_substring_before [line 3970]

(mixed) _handleFunction_substring_before( $arguments $arguments, $context $context)

Handles the XPath function substring-before.



Tags:

return:  Depending on the type of function being processed
see:  XPathEngine::evaluate()


Parameters:

$arguments   $arguments   (string) String containing the arguments that were passed to the function.
$context   $context   (array) The context from which to evaluate the function

[ Top ]

method _handleFunction_sum [line 4231]

(mixed) _handleFunction_sum( $arguments $arguments, $context $context)

Handles the XPath function sum.



Tags:

return:  Depending on the type of function being processed
see:  XPathEngine::evaluate()


Parameters:

$arguments   $arguments   (string) String containing the arguments that were passed to the function.
$context   $context   (array) The context from which to evaluate the function

[ Top ]

method _handleFunction_translate [line 4072]

(mixed) _handleFunction_translate( $arguments $arguments, $context $context)

Handles the XPath function translate.



Tags:

return:  Depending on the type of function being processed
see:  XPathEngine::evaluate()


Parameters:

$arguments   $arguments   (string) String containing the arguments that were passed to the function.
$context   $context   (array) The context from which to evaluate the function

[ Top ]

method _handleFunction_true [line 4152]

(mixed) _handleFunction_true( $arguments $arguments, $context $context)

Handles the XPath function TRUE.



Tags:

return:  Depending on the type of function being processed
see:  XPathEngine::evaluate()


Parameters:

$arguments   $arguments   (string) String containing the arguments that were passed to the function.
$context   $context   (array) The context from which to evaluate the function

[ Top ]

method _handleFunction_x_lower [line 4311]

(mixed) _handleFunction_x_lower( $arguments $arguments, $context $context)

Handles the XPath function x-lower.

lower case a string. string x-lower(string)




Tags:

return:  Depending on the type of function being processed
see:  XPathEngine::evaluate()


Parameters:

$arguments   $arguments   (string) String containing the arguments that were passed to the function.
$context   $context   (array) The context from which to evaluate the function

[ Top ]

method _handleFunction_x_upper [line 4329]

(mixed) _handleFunction_x_upper( $arguments $arguments, $context $context)

Handles the XPath function x-upper.

upper case a string. string x-upper(string)




Tags:

return:  Depending on the type of function being processed
see:  XPathEngine::evaluate()


Parameters:

$arguments   $arguments   (string) String containing the arguments that were passed to the function.
$context   $context   (array) The context from which to evaluate the function

[ Top ]

method _handlePI [line 1887]

void _handlePI( $parser $parser, $target $target, $data $data)

Handles processing instruction (PI)

A processing instruction has the following format: <? target data ? > e.g. <? dtd version="1.0" ? >

Currently I have no bether idea as to left it 'as is' and treat the PI data as normal text (and adding the surrounding PI-tags <? ? >).




Tags:

see:  PHP's manual "xml_set_processing_instruction_handler"


Parameters:

$parser   $parser   (int) Handler for accessing the current XML parser.
$target   $target   (string) Name of the PI target. E.g. XML, PHP, DTD, ...
$data   $data   (string) Associative array containing a list of

[ Top ]

method _handleStartElement [line 1718]

void _handleStartElement( $parser $parser, $name $nodeName, $attributes $attributes)

Handles opening XML tags while parsing.

While parsing a XML document for each opening tag this method is called. It'll add the tag found to the tree of document nodes.




Tags:



Parameters:

$parser   $parser   (int) Handler for accessing the current XML parser.
$name   $nodeName   (string) Name of the opening tag found in the document.
$attributes   $attributes   (array) Associative array containing a list of all attributes of the tag found in the document.

[ Top ]

method _internalAppendChild [line 1933]

(bool) _internalAppendChild( $stackParentIndex $stackParentIndex, $nodeName $nodeName)

Adds a new node to the XML document tree during xml parsing.

This method adds a new node to the tree of nodes of the XML document being handled by this class. The new node is created according to the parameters passed to this method. This method is a much watered down version of appendChild(), used in parsing an xml file only.

It is assumed that adding starts with root and progresses through the document in parse order. New nodes must have a corresponding parent. And once we have read the </> tag for the element we will never need to add any more data to that node. Otherwise the add will be ignored or fail.

The function is faciliated by a nodeStack, which is an array of nodes that we have yet to close.




Tags:

return:  TRUE if we successfully added a new child to the node stack at index $stackParentIndex + 1, FALSE on error.


Parameters:

$stackParentIndex   $stackParentIndex   (int) The index into the nodeStack[] of the parent node to which the new node should be added as a child. *READONLY*
$nodeName   $nodeName   (string) Name of the new node. *READONLY*

[ Top ]

method _InternalExport [line 1262]

(string) _InternalExport( $node $node)

Export the xml document starting at the named node.



Tags:

return:  The string representation of the node.


Parameters:

$node   $node   (node) The node we have to start exporting from

[ Top ]

method _recursiveReindexNodeTree [line 2040]

(bool) _recursiveReindexNodeTree( $absoluteParentPath $absoluteParentPath)

Here's where the work is done for reindexing (see reindexNodeTree)



Tags:

return:  TRUE on success, FALSE otherwise.
see:  XPathEngine::reindexNodeTree()


Parameters:

$absoluteParentPath   $absoluteParentPath   (string) the xPath to the parent node

[ Top ]

method _removeLiterals [line 2296]

(string) _removeLiterals( $xPathQuery $xPathQuery)

Parse out the literals of an XPath expression.

Instead of doing a full lexical parse, we parse out the literal strings, and then Treat the sections of the string either as parts of XPath or literal strings. So this function replaces each literal it finds with a literal reference, and then inserts the reference into an array of strings that we can access. The literals can be accessed later from the literals associative array.

Example: XPathExpr = /AAA[@CCC = "hello"]/BBB[DDD = 'world'] => literals: array("hello", "world") return value: /AAA[@CCC = $1]/BBB[DDD = $2]

Note: This does not interfere with the VariableReference syntactical element, as these elements must not start with a number.




Tags:

return:  The XPath expression without the literals.


Parameters:

$xPathQuery   $xPathQuery   (string) XPath expression to be processed

[ Top ]

method _sortByDocOrder [line 2864]

(array) _sortByDocOrder( $xPathSet $xPathSet)

Sort an xPathSet by doc order.



Tags:

return:  Array containing the same contents as $xPathSet, but with the contents in doc order


Parameters:

$xPathSet   $xPathSet   (array) Array of full paths to nodes that need to be sorted

[ Top ]

method _translateAmpersand [line 4498]

(string) _translateAmpersand( $xmlSource $xmlSource, [mixed $reverse = FALSE])

Translate all ampersands to it's literal entities '&amp;' and back.

I wasn't aware of this problem at first but it's important to understand why we do this. At first you must know: a) PHP's XML parser *translates* all entities to the equivalent char E.g. &lt; is returned as '<' b) PHP's XML parser (in V 4.1.0) has problems with most *literal* entities! The only one's that are recognized are &amp;, &lt; &gt; and &quot;. *ALL* others (like &nbsp; &copy; a.s.o.) cause an XML_ERROR_UNDEFINED_ENTITY error. I reported this as bug at http://bugs.php.net/bug.php?id=15092 (It turned out not to be a 'real' bug, but one of those nice W3C-spec things).

Forget position b) now. It's just for info. Because the way we will solve a) will also solve b) too.

THE PROBLEM To understand the problem, here a sample: Given is the following XML: "<AAA> &lt; &nbsp; &gt; </AAA>" Try to parse it and PHP's XML parser will fail with a XML_ERROR_UNDEFINED_ENTITY becaus of the unknown litteral-entity '&nbsp;'. (The numeric equivalent '&#160;' would work though). Next try is to use the numeric equivalent 160 for '&nbsp;', thus "<AAA> &lt; &#160; &gt; </AAA>" The data we receive in the tag <AAA> is " < > ". So we get the *translated entities* and NOT the 3 entities &lt; &#160; &gt. Thus, we will not even notice that there were entities at all! In *most* cases we're not able to tell if the data was given as entity or as 'normal' char. E.g. When receiving a quote or a single space were not able to tell if it was given as 'normal' char or as &nbsp; or &quot;. Thus we loose the entity-information of the XML-data!

THE SOLUTION The better solution is to keep the data 'as is' by replacing the '&' before parsing begins. E.g. Taking the original input from above, this would result in "<AAA> &amp;lt; &amp;nbsp; &amp;gt; </AAA>" The data we receive now for the tag <AAA> is " &lt; &nbsp; &gt; ". and that's what we want.

The bad thing is, that a global replace will also replace data in section that are NOT translated by the PHP XML-parser. That is comments (<!-- -->), IP-sections (stuff between <? ? >) and CDATA-block too. So all data comming from those sections must be reversed. This is done during the XML parse phase. So: a) Replacement of all '&' in the XML-source. b) All data that is not char-data or in CDATA-block have to be reversed during the XML-parse phase.




Tags:

return:  The XML string with translated ampersands.


Parameters:

$xmlSource   $xmlSource   (string) The XML string

[ Top ]


Documentation generated on Mon, 29 Dec 2003 21:16:32 +0100 by phpDocumentor 1.2.3