Class definition: eXcavator
Located in /eXcavator.inc (line 165)
Either the XML document string or file name of XML document
Either one of two defined constants: eXcavator_STRING or eXcavator_FILE
This is the result array, created in _setDATA as conditions are evaluated as TRUE
Used by eXcavator_getFormattedText
Constructor for eXcavator
AND's expressions in $condition; loops through each expression in AND-ed sequence and returns false at first one to be found false, otherwise true
SYNTAX:
The syntax of _AND_ and _OR has two formats. One format applies if all the expressions in the condition are descendents of the context element to the left of the brackets and are of the same type:
But both _AND_ and _OR have a more comprehensive syntax, which allows for mixing of types and for the introduction of additional contexts into the condition. Here are the rules which govern the expanded syntax:
All the elements being searched must appear in the tokenized array $token, which is passed in as a parameter. That is, all of the items being evaluated must be descendents of a governing context-element. They don't have to be first-generation children, only descendents.
Frees XML_PullParser resources
Must be called if running sequenctial instances of eXcavator, for instance in a loop
Gets formatted text based on a template
The template format is:
optional-text {selector} optional-text {selector} . . .
The optional text will be reproduced verbatim from the template. The selectors locate and identify data.
The basic selector consists of an element name:
{first_name}
or of the element name followed by a semi-colon and the name of an attribute:
{first_name;middle_init}
If there is more than one element of the same name in a context, it can be addressed using an indirect addressing mode:
{ owner=>city[1] } This selects the first city element in the owner element.
Text formatting is fully treated in the Manual.
Returns a copy of the raw result array eXcavator_result_array
Returns an indexed array of results in which each result is an associative array; its keys are the element names and their values are arrays which hold the element data
[0] => Array (
[element]=> array
(
[cdata] => string value
[attr] => semi-colon separated string of
attributes: name="value";name="value"
)
}
[1] => Array {
)This array is suitable for passing in to a function for further processing.
This method loops through eXcavator_result_array sending one result at a time to _parseResultAsData where the result is converted to the associative array
Deprecated
This is an internal function
Converts $eXcavator_result_array to string in XML format
Converts result from eXcavator_getResultAsString to
well-formed XML string
Returns number of results found by query
OR's condition
loops through each expression in Or-ed sequence and returns true at first one to be found true, otherwise false
For details on how to use this method see eXcavator_AND. What is said there applies to eXcavator_OR, except for the fact that this method OR's instead of AND's the conditions.
Constructor for eXcavator
This parses the relationship of a condition expression and passes on the result to _hasRelation() where its truth value is determined
An informational facility. Designed for use when creating patterns for eXcavator_getFormattedText.
It returns an array that is mapped to the requested element structure, showing the the elements it holds and their contents, both character data and attributes. In the output, duplicate element names are indexed using a triple underscore followed the its number, as in:
___1
The numbering begins with the second element, which is element___1. The first element found does not have an index attached to it.
This is the indexing that is used for direct addressing by eXcavator_getFormattedText.
This method returns only the first element named $element. If there is more than one element of the same name, for which a result is desired, then each subsequent element of that name must be addressed with its numeric index. If, for instance, an element named book has three authors, a request for book will return an array that includes author, author___1, and author___2. But if the request is for author, then only the first author element, with its children, will be returned. Separate requests would have to be made for author___1 and author___2.
An informational facility for use with eXcavator_getFormattedText. It returns a string which lists the names of all the elements held in the designated element structure.
The returned string is based on the array returned from eXcavator_showSchemeAsArray so that the commentary on that method applies to this as well.
This sends the condition string to _checkCondition(), where each condition is processed and the result is passed on to _setDATA()}.
If _checkCondition() finds that there is more than one condition in the condition string, it returns an array of the conditions contained in the condition string and then r_test() iterates through the array and sends one condition at a time back to _checkCondition().
Parses the condition and determines the value of query
Determines operator type, type of condition (CDATA, ATTR), extracts the relevant children of $token and routes them to the proper operator method, collects each child that satisfies the condition in a result array and puts that in &$found_array or else if testing for the values of a descendent, it puts the ancestor array, which is extracted from $token, into &$found_array
main method variables:
Called by eXcavator_getFormattedText to locate data held in descendent elements when the patterns use indirect addressing
Determines if there is an element which matches the element in the condition
extracts operator from condition
Creates a key for each result element, which is a treated as a branch; called by _setUserResultArray to create the array needed by eXcavator_getFormattedText
What this method does, in effect, is to create an associative array of associative arrays, in which each element that has descendents is a separate associative array branching off the top level array. The associative array of descendents elements in turn holds the data in sets of associative arrays as described below.
This method works on a result array returned by _getResultAsDataStruct which creates a key for each element and if necessary numbers them and then sets each key to an array which holds the data for attributes and cdata:
[element]=> array
(
[cdata] => string value
[attr] => semi-colon separated
string attributes: name="value";name="value"
) _getResultAsBranchedArray creates the structure $branches[$branch] at the top level. If the branch has descendent elements it creates a key for each of those under the branch: $branches[$branch][$el], and then sets these to their values, as described in the paragraph above.
Loops through eXcavator_result_array to create raw array for eXcavator_getFormattedText
Determines whether a relation is TRUE or FALSE
This method aligns each element with its conditions It passes the element name and its condition string to r_test(), which sends each condition to _checkCondition(), where the condition is evaluated.
Converts XML_PullParser tokenized array to string
Called by eXcavator_getResultAsString which loops through the result array one result at a time, sending it here for string-izing
Does work of creating arrays for eXcavator_result_array
Creates result array in conformance with XML_PullParser_getChildren()
As conditions are met in _checkCondition, the results are passed to this method by r_test, and they are saved here in the result array eXcavator_result_array
Converts array returned by _getResultAsDataStruct()
to form suitable for use by eXcavator_getFormattedText
Documentation generated on Mon, 30 Oct 2006 07:00:59 -0500 by phpDocumentor 1.3.0RC6