Handle EC key types in a couple of methods.
[shibboleth/cpp-xmltooling.git] / xmltooling / AbstractDOMCachingXMLObject.cpp
index 775b4bc..684b466 100644 (file)
@@ -55,11 +55,15 @@ DOMElement* AbstractDOMCachingXMLObject::getDOM() const
 
 void AbstractDOMCachingXMLObject::setDOM(DOMElement* dom, bool bindDocument) const
 {
-    m_dom=dom;
-    if (dom) {
-        if (bindDocument) {
-            setDocument(dom->getOwnerDocument());
-        }
+    m_dom = dom;
+    if (dom && bindDocument) {
+        DOMDocument* doc = dom->getOwnerDocument();
+        setDocument(doc);
+        DOMElement* documentRoot = doc->getDocumentElement();
+        if (!documentRoot)
+            doc->appendChild(dom);
+        else if (documentRoot != dom)
+            doc->replaceChild(dom, documentRoot);
     }
 }