/** *@param DOMDocument $xmlDom - XmlDocument to be parsed *@param string $tagName - Tag to be looked for *@param string $attribute - Attribute within tag to be looked for *@return void *@desc Process XHTML files and look for HREF attributes and change "engine:xmlnuke" and "module:..." *contents to FULL QUALIFIED VIRTUAL PATH and XMLNUke's context params */ public function AdjustToFullLink($xmlDom, $tagName, $attribute) { $xpath = new DOMXPath($xmlDom); XmlUtil::registerNamespaceForFilter($xpath, array('x' => 'http://www.w3.org/1999/xhtml')); $nodeList = $xpath->query("//" . strtolower($tagName) . " | //" . strtoupper($tagName) . " | //x:" . strtolower($tagName) . " | //x:" . strtoupper($tagName)); foreach ($nodeList as $node) { $strAtributeUp = strtoupper($attribute); $strAtributeLow = strtolower($attribute); if ($node->hasAttribute($strAtributeUp)) { $node->setAttribute($strAtributeUp, $this->GetFullLink($node->getAttribute($strAtributeUp))); } if ($node->hasAttribute($strAtributeLow)) { $node->setAttribute($strAtributeLow, $this->GetFullLink($node->getAttribute($strAtributeLow))); } } }
/** * Returns a \DOMNodeList from a relative xPath from other \DOMNode * * @param \DOMNode $pNode * @param string $xPath * @param array $arNamespace * @return DOMNodeList */ public static function selectNodes(\DOMNode $pNode, $xPath, $arNamespace = null) { if (preg_match('~^/[^/]~', $xPath)) { $xPath = substr($xPath, 1); } $owner = XmlUtil::getOwnerDocument($pNode); $xp = new DOMXPath($owner); XmlUtil::registerNamespaceForFilter($xp, $arNamespace); $rNodeList = $xp->query($xPath, $pNode); return $rNodeList; }