DOM_Node RangeImpl::removeChild(DOM_Node& parent, DOM_Node& child) { fRemoveChild = child; //only a precaution measure not to update this range data before removal DOM_Node n = parent.removeChild(child); fRemoveChild = null; return n; }
//====================================================================== // CJM 4/17/03 ..Needed to update an attribute list... for ContentGuard //====================================================================== bool XMLDocument::setAttributeList(char* path, DataTypeAttribute** dtAttributes) { if (mDoc == NULL) return false; if (path == NULL) return false; DOM_Node child = getNode(mRootNode, path, NULL); char* value = getString(path); if (child == NULL) return false; short nType = child.getNodeType(); DOM_Node parent = child.getParentNode(); if (parent == NULL) return false; char* childName = child.getNodeName().transcode(); DOM_NamedNodeMap nnodeMap = child.getAttributes(); parent.removeChild(child); DOM_Element childElement = mDoc.createElement(childName); delete[] childName; int a = 0; DataTypeAttribute* dtAttribute; while ((dtAttribute = (DataTypeAttribute*)dtAttributes[a++]) != (DataTypeAttribute*)NULL) { childElement.setAttribute(dtAttribute->getName(), dtAttribute->getValue()); } if (nType == DOM_Node::TEXT_NODE) { DOM_Text childText = mDoc.createTextNode((value == NULL)?"":value); childElement.appendChild(childText); } else { if (nType == DOM_Node::CDATA_SECTION_NODE) { DOM_CDATASection childCData = mDoc.createCDATASection((value == NULL)?"":value); childElement.appendChild(childCData); } } parent.appendChild(childElement); return true; }
//====================================================================== //====================================================================== bool XMLDocument::setValue(DOM_Node currNode, char* path, DataTypeAttribute** dtAttributes, char* value) { if (mDoc == NULL) return false; if (path == NULL) return false; DOM_Node child = getNode(currNode, path, dtAttributes); if (child == NULL) return false; DOM_Node parent = child.getParentNode(); if (parent == NULL) return false; DOM_Node grandChild = child.getFirstChild(); short nType = DOM_Node::TEXT_NODE; if (grandChild != NULL) { nType = grandChild.getNodeType(); if (nType != DOM_Node::TEXT_NODE && nType != DOM_Node::CDATA_SECTION_NODE) return false; } char* childName = child.getNodeName().transcode(); DOM_NamedNodeMap nnodeMap = child.getAttributes(); parent.removeChild(child); DOM_Element childElement = mDoc.createElement(childName); delete[] childName; for (unsigned int i = 0; i < nnodeMap.getLength(); i++) { DOM_Node attNode = nnodeMap.item(i); childElement.setAttribute(attNode.getNodeName(), attNode.getNodeValue()); } if (nType == DOM_Node::TEXT_NODE) { DOM_Text childText = mDoc.createTextNode((value == NULL)?"":value); childElement.appendChild(childText); } else { DOM_CDATASection childCData = mDoc.createCDATASection((value == NULL)?"":value); childElement.appendChild(childCData); } parent.appendChild(childElement); return true; }