diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2015-03-11 15:35:11 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2015-03-11 15:35:11 +0200 |
commit | 939d5ad2a285a42819a39f7155ed3f672014d4ed (patch) | |
tree | bdcf20a2a91730c8f640bad34e67c35524ef0d49 /examples/cxx | |
parent | 3d3ac8cec9f1d759cf23952a39da62ba716a9ea1 (diff) |
Update namespace stack when resetting document in streaming example
Diffstat (limited to 'examples/cxx')
-rw-r--r-- | examples/cxx/tree/streaming/serializer.cxx | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/examples/cxx/tree/streaming/serializer.cxx b/examples/cxx/tree/streaming/serializer.cxx index 0ce8156..e6513bc 100644 --- a/examples/cxx/tree/streaming/serializer.cxx +++ b/examples/cxx/tree/streaming/serializer.cxx @@ -5,6 +5,7 @@ #include <xercesc/util/XMLUni.hpp> #include <xercesc/dom/DOM.hpp> +#include <xercesc/dom/impl/DOMDocumentImpl.hpp> #include <xercesc/dom/impl/DOMLSSerializerImpl.hpp> #include <xsd/cxx/xml/string.hxx> @@ -216,6 +217,7 @@ public: fNamespaceStack->addElement(namespaceMap); } namespaceMap->put((void*)prefix,(XMLCh*)uri); + *fFormatter << XMLFormatter::NoEscapes << chSpace << XMLUni::fgXMLNSString << chColon << prefix << chEqual << chDoubleQuote @@ -327,6 +329,29 @@ public: using DOMLSSerializerImpl::write; // Whole document. +public: + // Update the namespace stack to point to the strings from the + // new document's string pool. + // + void + update_namespace_stack (DOMDocument& d) + { + DOMDocumentImpl& di (dynamic_cast<DOMDocumentImpl&> (d)); + + for (XMLSize_t i (0); i != fNamespaceStack->size (); ++i) + { + RefHashTableOf<XMLCh>& t (*fNamespaceStack->elementAt (i)); + RefHashTableOfEnumerator<XMLCh> e (&t, false, fMemoryManager); + while (e.hasMoreElements ()) + { + XMLCh* k ((XMLCh*) (e.nextElementKey ())); + XMLCh* v (t.get (k)); + t.put ((void*) (di.getPooledString (k)), + (XMLCh*) (di.getPooledString (v))); + } + } + } + private: XMLFormatTarget* target_; std::auto_ptr<XMLFormatter> formatter_; @@ -551,6 +576,10 @@ clear_document () } } + // Update the namespace stack to use the new document. + // + serializer_->update_namespace_stack (*doc); + doc_ = doc; element_count_ = 0; } |