https://bugs.internet2.edu/jira/browse/CPPXT-61
authorcantor <cantor@de75baf8-a10c-0410-a50a-987c0e22f00f>
Wed, 18 Aug 2010 16:06:04 +0000 (16:06 +0000)
committercantor <cantor@de75baf8-a10c-0410-a50a-987c0e22f00f>
Wed, 18 Aug 2010 16:06:04 +0000 (16:06 +0000)
git-svn-id: https://svn.middleware.georgetown.edu/cpp-xmltooling/branches/REL_1@768 de75baf8-a10c-0410-a50a-987c0e22f00f

xmltooling/AbstractDOMCachingXMLObject.cpp

index 775b4bc..38c25cc 100644 (file)
@@ -55,10 +55,18 @@ DOMElement* AbstractDOMCachingXMLObject::getDOM() const
 
 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);
+            }
         }
     }
 }