+ unk->releaseParentDOM(true);\r
+ unk->m_xml.erase();\r
+ return cachedDOM;\r
+}\r
+\r
+DOMElement* UnknownElementMarshaller::marshall(XMLObject* xmlObject, DOMElement* parentElement) const\r
+{\r
+#ifdef _DEBUG\r
+ xmltooling::NDC ndc("marshall");\r
+#endif\r
+ \r
+ Category& log=Category::getInstance(XMLTOOLING_LOGCAT".Marshaller");\r
+ log.debug("marshalling unknown content");\r
+\r
+ UnknownElementImpl* unk=dynamic_cast<UnknownElementImpl*>(xmlObject);\r
+ if (!unk)\r
+ throw MarshallingException("Only objects of class UnknownElementImpl can be marshalled.");\r
+ \r
+ DOMElement* cachedDOM=unk->getDOM();\r
+ if (cachedDOM) {\r
+ if (parentElement->getOwnerDocument()==cachedDOM->getOwnerDocument()) {\r
+ log.debug("XMLObject has a usable cached DOM, reusing it");\r
+ parentElement->appendChild(cachedDOM);\r
+ unk->releaseParentDOM(true);\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
+ }\r
+ \r
+ // If we get here, we didn't have a usable DOM (and/or we flushed the one we had).\r
+ // We need to reparse the XML we saved off into a new DOM.\r
+ MemBufInputSource src(reinterpret_cast<const XMLByte*>(unk->m_xml.c_str()),unk->m_xml.length(),"UnknownElementImpl");\r
+ Wrapper4InputSource dsrc(&src,false);\r
+ log.debug("parsing XML back into DOM tree");\r
+ DOMDocument* internalDoc=XMLToolingInternalConfig::getInternalConfig().m_parserPool->parse(dsrc);\r
+ \r
+ log.debug("reimporting new DOM into caller-supplied document");\r
+ cachedDOM=static_cast<DOMElement*>(parentElement->getOwnerDocument()->importNode(internalDoc->getDocumentElement(), true));\r
+ internalDoc->release();\r
+\r
+ // Recache the DOM and clear the serialized copy.\r
+ parentElement->appendChild(cachedDOM);\r
+ log.debug("caching DOM for XMLObject");\r
+ unk->setDOM(cachedDOM, false);\r
+ unk->releaseParentDOM(true);\r