public function addCondition($condition)
{
if ($this->condition) {
$this->condition = sprintf('%s and (%s)', $this->condition, $condition);
} else {
$this->condition = $condition;
}
}
/** * Joins an XPath expression as an adjacent of another. * * @param XPathExpr $xpath The parent XPath expression * @param NodeInterface $sub The adjacent XPath expression * * @return XPathExpr An XPath instance */ protected function _xpath_direct_adjacent($xpath, $sub) { // when sub immediately follows xpath $xpath->join('/following-sibling::', $sub->toXpath()); $xpath->addNameTest(); $xpath->addCondition('position() = 1'); return $xpath; }