diff options
Diffstat (limited to 'examples/cxx/tree/streaming')
-rw-r--r-- | examples/cxx/tree/streaming/parser.cxx | 36 | ||||
-rw-r--r-- | examples/cxx/tree/streaming/serializer.cxx | 22 |
2 files changed, 3 insertions, 55 deletions
diff --git a/examples/cxx/tree/streaming/parser.cxx b/examples/cxx/tree/streaming/parser.cxx index f593a14..4696d5c 100644 --- a/examples/cxx/tree/streaming/parser.cxx +++ b/examples/cxx/tree/streaming/parser.cxx @@ -11,10 +11,7 @@ #include <xercesc/sax2/XMLReaderFactory.hpp> #include <xercesc/dom/DOM.hpp> - -#if _XERCES_VERSION >= 30000 -# include <xercesc/dom/impl/DOMTextImpl.hpp> -#endif +#include <xercesc/dom/impl/DOMTextImpl.hpp> #include <xsd/cxx/auto-array.hxx> @@ -59,12 +56,7 @@ private: virtual void characters (const XMLCh* const s, -#if _XERCES_VERSION >= 30000 - const XMLSize_t length -#else - const unsigned int length -#endif - ); + const XMLSize_t length); private: // SAX parser. @@ -101,7 +93,7 @@ parser_impl () // Xerces-C++ 3.1.0 is the first version with working multi import // support. It also allows us to disable buffering in the parser - // so that the date is parsed and returned as soon as it is + // so that the data is parsed and returned as soon as it is // available. // #if _XERCES_VERSION >= 30100 @@ -214,11 +206,7 @@ startElement (const XMLCh* const uri, // Set attributes. // -#if _XERCES_VERSION >= 30000 for (XMLSize_t i (0), end (attr.getLength()); i < end; ++i) -#else - for (unsigned int i (0), end (attr.getLength()); i < end; ++i) -#endif { const XMLCh* qn (attr.getQName (i)); const XMLCh* ns (attr.getURI (i)); @@ -247,7 +235,6 @@ endElement (const XMLCh* const /*uri*/, cur_ = static_cast<DOMElement*> (cur_->getParentNode ()); } -#if _XERCES_VERSION >= 30000 void parser_impl:: characters (const XMLCh* const s, const XMLSize_t length) { @@ -262,23 +249,6 @@ characters (const XMLCh* const s, const XMLSize_t length) cur_->appendChild (t); } } -#else -void parser_impl:: -characters (const XMLCh* const s, const unsigned int length) -{ - // Ignore text content (presumably whitespaces) in the root element. - // - if (depth_ > 1) - { - // For Xerces-C++ 2-series we have to make copy. - // - xsd::cxx::auto_array<XMLCh> tmp (new XMLCh[length + 1]); - XMLString::copyNString (tmp.get (), s, length); - cur_->appendChild (doc_->createTextNode (tmp.get ())); - } -} -#endif - // // parser diff --git a/examples/cxx/tree/streaming/serializer.cxx b/examples/cxx/tree/streaming/serializer.cxx index f6516f6..c879533 100644 --- a/examples/cxx/tree/streaming/serializer.cxx +++ b/examples/cxx/tree/streaming/serializer.cxx @@ -47,12 +47,8 @@ private: private: // Serializer. // -#if _XERCES_VERSION >= 30000 xml::dom::auto_ptr<DOMLSOutput> out_; xml::dom::auto_ptr<DOMLSSerializer> serializer_; -#else - xml::dom::auto_ptr<DOMWriter> serializer_; -#endif auto_ptr<xml::dom::ostream_format_target> oft_; @@ -73,7 +69,6 @@ serializer_impl () dom_impl_ (*DOMImplementationRegistry::getDOMImplementation (ls)), doc_ (dom_impl_.createDocument ()) { -#if _XERCES_VERSION >= 30000 serializer_.reset (dom_impl_.createLSSerializer ()); DOMConfiguration* conf (serializer_->getDomConfig ()); @@ -81,14 +76,6 @@ serializer_impl () conf->setParameter (XMLUni::fgDOMWRTDiscardDefaultContent, true); conf->setParameter (XMLUni::fgDOMWRTFormatPrettyPrint, true); conf->setParameter (XMLUni::fgDOMXMLDeclaration, false); -#else - serializer_.reset (dom_impl_.createDOMWriter ()); - - serializer_->setErrorHandler (&error_proxy_); - serializer_->setFeature (XMLUni::fgDOMWRTDiscardDefaultContent, true); - serializer_->setFeature (XMLUni::fgDOMWRTFormatPrettyPrint, true); - serializer_->setFeature (XMLUni::fgDOMXMLDeclaration, false); -#endif } void serializer_impl:: @@ -97,13 +84,9 @@ start (ostream& os, const string& encoding) error_handler_.reset (); oft_.reset (new xml::dom::ostream_format_target (os)); -#if _XERCES_VERSION >= 30000 out_.reset (dom_impl_.createLSOutput ()); out_->setEncoding (xml::string (encoding).c_str ()); out_->setByteStream (oft_.get ()); -#else - serializer_->setEncoding (xml::string (encoding).c_str ()); -#endif } DOMElement* serializer_impl:: @@ -159,12 +142,7 @@ add_namespaces (DOMElement* e, const namespace_infomap& map) void serializer_impl:: serialize (DOMElement& e) { -#if _XERCES_VERSION >= 30000 serializer_->write (&e, out_.get ()); -#else - serializer_->writeNode (oft_.get (), e); -#endif - error_handler_.throw_if_failed<tree::serialization<char> > (); } |