/** * Combination of AddChildNode or RedefineChildNode... it depends * This should become the preferred way of doing things (instead of implementing a test + the call to one of the APIs! * @param MFElement $oNode The node (including all subnodes) to set */ public function SetChildNode(MFElement $oNode, $sSearchId = null) { // First: cleanup any flag behind the new node, and eventually add trace data $oNode->ApplyChanges(); $oNode->AddTrace(); $oExisting = $this->_FindChildNode($oNode, $sSearchId); if ($oExisting) { $sPrevFlag = $oExisting->getAttribute('_alteration'); if ($sPrevFlag == 'removed') { $sFlag = 'replaced'; } else { $sFlag = $sPrevFlag; // added, replaced or '' } $oExisting->ReplaceWith($oNode); } else { $this->appendChild($oNode); $sFlag = 'added'; } if (!$this->IsInDefinition()) { if ($sFlag == '') { $sFlag = 'replaced'; } $oNode->setAttribute('_alteration', $sFlag); } }