From bada6666c70977a058755ccf232e7d67b24adeed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Wed, 23 Jul 2014 15:21:29 +0200 Subject: New upstream release --- xsd/libxsd/xsd/cxx/xml/dom/parsing-source.txx | 226 ++++++-------------------- 1 file changed, 48 insertions(+), 178 deletions(-) (limited to 'xsd/libxsd/xsd/cxx/xml/dom/parsing-source.txx') diff --git a/xsd/libxsd/xsd/cxx/xml/dom/parsing-source.txx b/xsd/libxsd/xsd/cxx/xml/dom/parsing-source.txx index 50fa285..c789fa6 100644 --- a/xsd/libxsd/xsd/cxx/xml/dom/parsing-source.txx +++ b/xsd/libxsd/xsd/cxx/xml/dom/parsing-source.txx @@ -1,14 +1,10 @@ // file : xsd/cxx/xml/dom/parsing-source.txx -// author : Boris Kolpackov -// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC +// copyright : Copyright (c) 2005-2014 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file -#if _XERCES_VERSION >= 30000 -# include -# include -#else -# include -#endif +#include +#include + #include #include #include @@ -33,9 +29,9 @@ namespace xsd // template parser:: - parser (const xercesc::DOMElement& e, bool ep, bool ap) + parser (const xercesc::DOMElement& e, bool ep, bool tp, bool ap) : element_ (e), - next_element_ (0), + next_content_ (0), a_ (0), ai_ (0) { @@ -43,10 +39,21 @@ namespace xsd if (ep) { - for (next_element_ = e.getFirstChild (); - next_element_ != 0 && - next_element_->getNodeType () != DOMNode::ELEMENT_NODE; - next_element_ = next_element_->getNextSibling ()) /*noop*/; + for (next_content_ = e.getFirstChild ();; + next_content_ = next_content_->getNextSibling ()) + { + if (next_content_ == 0) + break; + + DOMNode::NodeType t (next_content_->getNodeType ()); + + if (t == DOMNode::ELEMENT_NODE) + break; + + if (tp && (t == DOMNode::TEXT_NODE || + t == DOMNode::CDATA_SECTION_NODE)) + break; + } } if (ap) @@ -58,20 +65,31 @@ namespace xsd template void parser:: - next_element () + next_content (bool tp) { using xercesc::DOMNode; - for (next_element_ = next_element_->getNextSibling (); - next_element_ != 0 && - next_element_->getNodeType () != DOMNode::ELEMENT_NODE; - next_element_ = next_element_->getNextSibling ())/*noop*/; + for (next_content_ = next_content_->getNextSibling ();; + next_content_ = next_content_->getNextSibling ()) + { + if (next_content_ == 0) + break; + + DOMNode::NodeType t (next_content_->getNodeType ()); + + if (t == DOMNode::ELEMENT_NODE) + break; + + if (tp && (t == DOMNode::TEXT_NODE || + t == DOMNode::CDATA_SECTION_NODE)) + break; + } } // parse() // template - xml::dom::auto_ptr + XSD_DOM_AUTO_PTR parse (xercesc::InputSource& is, error_handler& eh, const properties& prop, @@ -82,28 +100,13 @@ namespace xsd } template - auto_ptr + XSD_DOM_AUTO_PTR parse (xercesc::InputSource& is, xercesc::DOMErrorHandler& eh, const properties& prop, unsigned long flags) { - // HP aCC cannot handle using namespace xercesc; - // - using xercesc::DOMImplementationRegistry; - using xercesc::DOMImplementationLS; - using xercesc::DOMImplementation; - using xercesc::DOMDocument; -#if _XERCES_VERSION >= 30000 - using xercesc::DOMLSParser; - using xercesc::DOMConfiguration; -#else - using xercesc::DOMBuilder; -#endif - - using xercesc::Wrapper4InputSource; - using xercesc::XMLUni; - + using namespace xercesc; // Instantiate the DOM parser. // @@ -116,8 +119,7 @@ namespace xsd DOMImplementation* impl ( DOMImplementationRegistry::getDOMImplementation (ls_id)); -#if _XERCES_VERSION >= 30000 - auto_ptr parser ( + XSD_DOM_AUTO_PTR parser ( impl->createLSParser (DOMImplementationLS::MODE_SYNCHRONOUS, 0)); DOMConfiguration* conf (parser->getDomConfig ()); @@ -163,7 +165,6 @@ namespace xsd if (!(flags & no_muliple_imports)) conf->setParameter (XMLUni::fgXercesHandleMultipleImports, true); #endif - // This feature checks the schema grammar for additional // errors. We most likely do not need it when validating // instances (assuming the schema is valid). @@ -214,64 +215,9 @@ namespace xsd bits::error_handler_proxy ehp (eh); conf->setParameter (XMLUni::fgDOMErrorHandler, &ehp); -#else // _XERCES_VERSION >= 30000 - - // Same as above but for Xerces-C++ 2 series. - // - auto_ptr parser ( - impl->createDOMBuilder (DOMImplementationLS::MODE_SYNCHRONOUS, 0)); - - parser->setFeature (XMLUni::fgDOMComments, false); - parser->setFeature (XMLUni::fgDOMDatatypeNormalization, true); - parser->setFeature (XMLUni::fgDOMEntities, false); - parser->setFeature (XMLUni::fgDOMNamespaces, true); - parser->setFeature (XMLUni::fgDOMWhitespaceInElementContent, false); - - if (flags & dont_validate) - { - parser->setFeature (XMLUni::fgDOMValidation, false); - parser->setFeature (XMLUni::fgXercesSchema, false); - parser->setFeature (XMLUni::fgXercesSchemaFullChecking, false); - } - else - { - parser->setFeature (XMLUni::fgDOMValidation, true); - parser->setFeature (XMLUni::fgXercesSchema, true); - parser->setFeature (XMLUni::fgXercesSchemaFullChecking, false); - } - - parser->setFeature (XMLUni::fgXercesUserAdoptsDOMDocument, true); - - if (!prop.schema_location ().empty ()) - { - xml::string sl (prop.schema_location ()); - const void* v (sl.c_str ()); - - parser->setProperty ( - XMLUni::fgXercesSchemaExternalSchemaLocation, - const_cast (v)); - } - - if (!prop.no_namespace_schema_location ().empty ()) - { - xml::string sl (prop.no_namespace_schema_location ()); - const void* v (sl.c_str ()); - - parser->setProperty ( - XMLUni::fgXercesSchemaExternalNoNameSpaceSchemaLocation, - const_cast (v)); - } - - bits::error_handler_proxy ehp (eh); - parser->setErrorHandler (&ehp); - -#endif // _XERCES_VERSION >= 30000 - xercesc::Wrapper4InputSource wrap (&is, false); -#if _XERCES_VERSION >= 30000 - auto_ptr doc; - + XSD_DOM_AUTO_PTR doc; try { doc.reset (parser->parse (&wrap)); @@ -279,9 +225,7 @@ namespace xsd catch (const xercesc::DOMLSException&) { } -#else - auto_ptr doc (parser->parse (wrap)); -#endif + if (ehp.failed ()) doc.reset (); @@ -289,7 +233,7 @@ namespace xsd } template - xml::dom::auto_ptr + XSD_DOM_AUTO_PTR parse (const std::basic_string& uri, error_handler& eh, const properties& prop, @@ -300,26 +244,13 @@ namespace xsd } template - auto_ptr + XSD_DOM_AUTO_PTR parse (const std::basic_string& uri, xercesc::DOMErrorHandler& eh, const properties& prop, unsigned long flags) { - // HP aCC cannot handle using namespace xercesc; - // - using xercesc::DOMImplementationRegistry; - using xercesc::DOMImplementationLS; - using xercesc::DOMImplementation; - using xercesc::DOMDocument; -#if _XERCES_VERSION >= 30000 - using xercesc::DOMLSParser; - using xercesc::DOMConfiguration; -#else - using xercesc::DOMBuilder; -#endif - using xercesc::XMLUni; - + using namespace xercesc; // Instantiate the DOM parser. // @@ -332,8 +263,7 @@ namespace xsd DOMImplementation* impl ( DOMImplementationRegistry::getDOMImplementation (ls_id)); -#if _XERCES_VERSION >= 30000 - auto_ptr parser ( + XSD_DOM_AUTO_PTR parser ( impl->createLSParser(DOMImplementationLS::MODE_SYNCHRONOUS, 0)); DOMConfiguration* conf (parser->getDomConfig ()); @@ -430,63 +360,7 @@ namespace xsd bits::error_handler_proxy ehp (eh); conf->setParameter (XMLUni::fgDOMErrorHandler, &ehp); -#else // _XERCES_VERSION >= 30000 - - // Same as above but for Xerces-C++ 2 series. - // - auto_ptr parser ( - impl->createDOMBuilder(DOMImplementationLS::MODE_SYNCHRONOUS, 0)); - - parser->setFeature (XMLUni::fgDOMComments, false); - parser->setFeature (XMLUni::fgDOMDatatypeNormalization, true); - parser->setFeature (XMLUni::fgDOMEntities, false); - parser->setFeature (XMLUni::fgDOMNamespaces, true); - parser->setFeature (XMLUni::fgDOMWhitespaceInElementContent, false); - - if (flags & dont_validate) - { - parser->setFeature (XMLUni::fgDOMValidation, false); - parser->setFeature (XMLUni::fgXercesSchema, false); - parser->setFeature (XMLUni::fgXercesSchemaFullChecking, false); - } - else - { - parser->setFeature (XMLUni::fgDOMValidation, true); - parser->setFeature (XMLUni::fgXercesSchema, true); - parser->setFeature (XMLUni::fgXercesSchemaFullChecking, false); - } - - parser->setFeature (XMLUni::fgXercesUserAdoptsDOMDocument, true); - - if (!prop.schema_location ().empty ()) - { - xml::string sl (prop.schema_location ()); - const void* v (sl.c_str ()); - - parser->setProperty ( - XMLUni::fgXercesSchemaExternalSchemaLocation, - const_cast (v)); - } - - if (!prop.no_namespace_schema_location ().empty ()) - { - xml::string sl (prop.no_namespace_schema_location ()); - const void* v (sl.c_str ()); - - parser->setProperty ( - XMLUni::fgXercesSchemaExternalNoNameSpaceSchemaLocation, - const_cast (v)); - } - - bits::error_handler_proxy ehp (eh); - parser->setErrorHandler (&ehp); - -#endif // _XERCES_VERSION >= 30000 - - -#if _XERCES_VERSION >= 30000 - auto_ptr doc; - + XSD_DOM_AUTO_PTR doc; try { doc.reset (parser->parseURI (string (uri).c_str ())); @@ -494,10 +368,6 @@ namespace xsd catch (const xercesc::DOMLSException&) { } -#else - auto_ptr doc ( - parser->parseURI (string (uri).c_str ())); -#endif if (ehp.failed ()) doc.reset (); -- cgit v1.2.3