git-svn-id: https://svn.middleware.georgetown.edu/cpp-xmltooling/branches/REL_1@768
de75baf8-a10c-0410-a50a-
987c0e22f00f
void AbstractDOMCachingXMLObject::setDOM(DOMElement* dom, bool bindDocument) const
{
- m_dom=dom;
+ m_dom = dom;
if (dom) {
if (bindDocument) {
- setDocument(dom->getOwnerDocument());
+ DOMDocument* doc = dom->getOwnerDocument();
+ setDocument(doc);
+ if (dom) {
+ DOMElement* documentRoot = doc->getDocumentElement();
+ if (!documentRoot)
+ doc->appendChild(dom);
+ else if (documentRoot != dom)
+ doc->replaceChild(dom, documentRoot);
+ }
}
}
}