XMLHelper::serialize(getDOM(),s);\r
}\r
\r
-DOMElement* UnknownElementMarshaller::marshall(XMLObject* xmlObject, DOMDocument* document) const\r
+DOMElement* UnknownElementMarshaller::marshall(XMLObject* xmlObject, DOMDocument* document, MarshallingContext* ctx) const\r
{\r
#ifdef _DEBUG\r
xmltooling::NDC ndc("marshall");\r
return cachedDOM;\r
}\r
\r
- // We have a DOM but it doesn't match the document we were given. This both sucks and blows.\r
- // Without an adoptNode option to maintain the child pointers, we rely on our custom\r
- // implementation class to preserve the XML when we release the existing DOM.\r
- unk->releaseDOM();\r
+ // We have a DOM but it doesn't match the document we were given, so we import\r
+ // it into the new document.\r
+ cachedDOM=static_cast<DOMElement*>(document->importNode(cachedDOM, true));\r
+\r
+ // Recache the DOM.\r
+ setDocumentElement(document, cachedDOM);\r
+ log.debug("caching imported DOM for XMLObject");\r
+ unk->setDOM(cachedDOM, false);\r
+ unk->releaseParentDOM(true);\r
+ return cachedDOM;\r
}\r
\r
- // If we get here, we didn't have a usable DOM (and/or we flushed the one we had).\r
+ // If we get here, we didn't have a usable DOM.\r
// We need to reparse the XML we saved off into a new DOM.\r
bool bindDocument=false;\r
MemBufInputSource src(reinterpret_cast<const XMLByte*>(unk->m_xml.c_str()),unk->m_xml.length(),"UnknownElementImpl");\r
return cachedDOM;\r
}\r
\r
-DOMElement* UnknownElementMarshaller::marshall(XMLObject* xmlObject, DOMElement* parentElement) const\r
+DOMElement* UnknownElementMarshaller::marshall(XMLObject* xmlObject, DOMElement* parentElement, MarshallingContext* ctx) const\r
{\r
#ifdef _DEBUG\r
xmltooling::NDC ndc("marshall");\r
return cachedDOM;\r
}\r
\r
- // We have a DOM but it doesn't match the document we were given. This both sucks and blows.\r
- // Without an adoptNode option to maintain the child pointers, we rely on our custom\r
- // implementation class to preserve the XML when we release the existing DOM.\r
- unk->releaseDOM();\r
+ // We have a DOM but it doesn't match the document we were given, so we import\r
+ // it into the new document.\r
+ cachedDOM=static_cast<DOMElement*>(parentElement->getOwnerDocument()->importNode(cachedDOM, true));\r
+\r
+ // Recache the DOM.\r
+ parentElement->appendChild(cachedDOM);\r
+ log.debug("caching imported DOM for XMLObject");\r
+ unk->setDOM(cachedDOM, false);\r
+ unk->releaseParentDOM(true);\r
+ return cachedDOM;\r
}\r
\r
// If we get here, we didn't have a usable DOM (and/or we flushed the one we had).\r