https://issues.shibboleth.net/jira/browse/CPPXT-61
authorScott Cantor <cantor.2@osu.edu>
Wed, 18 Aug 2010 16:06:04 +0000 (16:06 +0000)
committerScott Cantor <cantor.2@osu.edu>
Wed, 18 Aug 2010 16:06:04 +0000 (16:06 +0000)
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);
+            }
         }
     }
 }