/** * undocumented function * * @param XPathExpr $xpath The XPath expression * * @return XPathExpr The modified expression */ protected function xpath_empty($xpath) { $xpath->addCondition('not(*) and not(normalize-space())'); return $xpath; }
/** * Joins an XPath expression as an indirect adjacent of another. * * @param XPathExpr $xpath The parent XPath expression * @param NodeInterface $sub The indirect adjacent NodeInterface object * * @return XPathExpr An XPath instance */ protected function _xpath_indirect_adjacent($xpath, $sub) { // when sub comes somewhere after xpath as a sibling $xpath->join('/following-sibling::', $sub->toXpath()); return $xpath; }
/** * Joins this XPath expression with $other (another XPath expression) using * $combiner to join them. * * @param string $combiner The combiner string. * @param XPathExpr $other The other XPath expression to combine with * this one. */ public function join($combiner, $other) { $prefix = (string) $this; $prefix .= $combiner; $path = $other->getPrefix() . $other->getPath(); /* We don't need a star prefix if we are joining to this other prefix; so we'll get rid of it */ if ($other->hasStarPrefix() && '*/' == $path) { $path = ''; } $this->prefix = $prefix; $this->path = $path; $this->element = $other->getElement(); $this->condition = $other->GetCondition(); }
public function addNameTest() { if ($this->element == '*') { // We weren't doing a test anyway return; } $this->addCondition(sprintf('name() = %s', XPathExpr::xpathLiteral($this->element))); $this->element = '*'; }
/** * undocumented function * * @param XPathExpr $xpath * @param XPathExpr $expr * * @return XPathExpr */ protected function _xpath_not($xpath, $expr) { // everything for which not expr applies $expr = $expr->toXpath(); $cond = $expr->getCondition(); // FIXME: should I do something about element_path? $xpath->addCondition(sprintf('not(%s)', $cond)); return $xpath; }