/** * Merge the current node into the given container * * @param DOMNode $oContainer An element or a document * @param string $sSearchId The id to consider (could be blank) * @param bool $bMustExist Throw an exception if the node must already be found (and not marked as deleted!) */ public function MergeInto($oContainer, $sSearchId, $bMustExist) { $oTargetNode = $oContainer->_FindChildNode($this, $sSearchId); if ($oTargetNode) { if ($oTargetNode->getAttribute('_alteration') == 'removed') { if ($bMustExist) { throw new Exception(MFDocument::GetItopNodePath($this) . ' at line ' . $this->getLineNo() . ": could not be found (marked as deleted)"); } // Beware: ImportNode(xxx, false) DOES NOT copy the node's attribute on *some* PHP versions (<5.2.17) // So use this workaround to import a node and its attributes on *any* PHP version $oTargetNode = $oContainer->ownerDocument->ImportNode($this->cloneNode(false), true); $oContainer->AddChildNode($oTargetNode); } } else { if ($bMustExist) { echo "Dumping parent node<br/>\n"; $oContainer->Dump(); throw new Exception(MFDocument::GetItopNodePath($this) . ' at line ' . $this->getLineNo() . ": could not be found"); } // Beware: ImportNode(xxx, false) DOES NOT copy the node's attribute on *some* PHP versions (<5.2.17) // So use this workaround to import a node and its attributes on *any* PHP version $oTargetNode = $oContainer->ownerDocument->ImportNode($this->cloneNode(false), true); $oContainer->AddChildNode($oTargetNode); } return $oTargetNode; }
/** * Merge the current node into the given container * * @param DOMNode $oContainer An element or a document * @param string $sSearchId The id to consider (could be blank) * @param bool $bMustExist Throw an exception if the node must already be found (and not marked as deleted!) */ public function MergeInto($oContainer, $sSearchId, $bMustExist) { $oTargetNode = $oContainer->_FindChildNode($this, $sSearchId); if ($oTargetNode) { if ($oTargetNode->getAttribute('_alteration') == 'removed') { if ($bMustExist) { throw new Exception("found mandatory node {$this->tagName}(id:{$sSearchId}) marked as deleted in " . $oContainer->getNodePath()); } // Beware: ImportNode(xxx, false) DOES NOT copy the node's attribute on *some* PHP versions (<5.2.17) // So use this workaround to import a node and its attributes on *any* PHP version $oTargetNode = $oContainer->ownerDocument->ImportNode($this->cloneNode(false), true); $oContainer->AddChildNode($oTargetNode); } } else { if ($bMustExist) { echo "Dumping parent node<br/>\n"; $oContainer->Dump(); throw new Exception("could not find {$this->tagName}(id:{$sSearchId}) in " . $oContainer->getNodePath()); } // Beware: ImportNode(xxx, false) DOES NOT copy the node's attribute on *some* PHP versions (<5.2.17) // So use this workaround to import a node and its attributes on *any* PHP version $oTargetNode = $oContainer->ownerDocument->ImportNode($this->cloneNode(false), true); $oContainer->AddChildNode($oTargetNode); } return $oTargetNode; }