* Resolves an xPathQuery vector depending on the property['modMatch']
*
* To:
* - all matches,
* - the first
* - none (If the query matches more then one node.)
* see setModMatch() for details
*
* @param $xPathQuery (string) An xpath query targeting a single node. If empty()
* returns the root node (if it exists).
* @param $function (string) The function in which this check was called
* @return (array) Vector of $absoluteXPath's (May be empty)
* @see setModMatch()
*/
function _resolveXPathQuery($xPathQuery, $function) {
$xPathSet = array();
do { // try-block
if (isSet($this->nodeIndex[$xPathQuery])) {
$xPathSet[] = $xPathQuery;
break; // try-block
}
if (empty($xPathQuery)) break; // try-block
if (substr($xPathQuery, -1) === '/') break; // If the xPathQuery ends with '/' then it cannot be a good query.
// If this xPathQuery is not absolute then attempt to evaluate it
$xPathSet = $this->match($xPathQuery);
$resultSize = sizeOf($xPathSet);
switch($this->properties['modMatch']) {
case XPATH_QUERYHIT_UNIQUE :
if ($resultSize >1) {
$xPathSet = array();
if ($this->properties['verboseLevel']) $this->_displayError("Canceled function '{$function}'. The query '{$xPathQuery}' mached {$resultSize} nodes and 'modMatch' is set to XPATH_QUERYHIT_UNIQUE.", __LINE__, __FILE__, FALSE);
}
break;
case XPATH_QUERYHIT_FIRST :
if ($resultSize >1) {
$xPathSet = array($xPathSet[0]);
if ($this->properties['verboseLevel']) $this->_displayError("Only modified first node in function '{$function}' because the query '{$xPathQuery}' mached {$resultSize} nodes and 'modMatch' is set to XPATH_QUERYHIT_FIRST.", __LINE__, __FILE__, FALSE);
}
break;
default: ; // DO NOTHING
}
} while (FALSE);
if ($this->properties['verboseLevel'] >= 2) $this->_displayMessage("'{$xPathQuery}' parameter from '{$function}' returned the following nodes: ".(count($xPathSet)?implode('<br>', $xPathSet):'[none]'), __LINE__, __FILE__);