From 9878dfe26a08ea5638c562c22c9becd11d462015 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 5 Nov 2009 06:49:41 +0200 Subject: Enable multiple import support for Xerces-C++ 3.1.0 or later --- NEWS | 9 ++++++--- documentation/cxx/parser/guide/index.xhtml | 5 +++++ examples/cxx/parser/performance/driver.cxx | 7 +++++++ examples/cxx/tree/caching/driver.cxx | 9 ++++++++- examples/cxx/tree/custom/comments/dom-parse.cxx | 7 +++++++ examples/cxx/tree/messaging/dom-parse.cxx | 7 +++++++ examples/cxx/tree/multiroot/dom-parse.cxx | 7 +++++++ examples/cxx/tree/performance/parsing.cxx | 7 +++++++ examples/cxx/tree/streaming/parser.cxx | 7 +++++++ examples/cxx/tree/xpath/dom-parse.cxx | 7 +++++++ libxsd/xsd/cxx/parser/xerces/elements.hxx | 2 +- libxsd/xsd/cxx/parser/xerces/elements.txx | 5 ++++- libxsd/xsd/cxx/xml/dom/parsing-source.txx | 10 ++++++++++ 13 files changed, 83 insertions(+), 6 deletions(-) diff --git a/NEWS b/NEWS index 451c032..45b0d1e 100644 --- a/NEWS +++ b/NEWS @@ -1,8 +1,11 @@ Version 3.3.0 - * When built with Xerces-C++ 3-series, enable handling of multiple - imports for the same namespace. Before, all subsequent imports for - a namespace were ignored which caused errors in some schemas. + * When the XSD compiler is built with Xerces-C++ 3.1.0 or later, enable + handling of multiple imports for the same namespace. Before all + subsequent imports for a namespace were ignored which caused errors + in some schemas. Note that if your application has XML Schema validation + enabled then you will also need to build it with Xerces-C++ 3.1.0 or + later to take advantage of this feature. * Warning id's have changed to start with a letter identifying the component issuing the warning. F - compiler frontend, D - compiler diff --git a/documentation/cxx/parser/guide/index.xhtml b/documentation/cxx/parser/guide/index.xhtml index 2c00e18..7379c96 100644 --- a/documentation/cxx/parser/guide/index.xhtml +++ b/documentation/cxx/parser/guide/index.xhtml @@ -3324,6 +3324,11 @@ namespace xml_schema // Do not initialize the Xerces-C++ runtime. // static const unsigned long dont_initialize; + + // Disable handling of subsequent imports for the same namespace + // in Xerces-C++ 3.1.0 and later. + // + static const unsigned long no_multiple_imports; }; class properties diff --git a/examples/cxx/parser/performance/driver.cxx b/examples/cxx/parser/performance/driver.cxx index 9e1d48d..0fe2f02 100644 --- a/examples/cxx/parser/performance/driver.cxx +++ b/examples/cxx/parser/performance/driver.cxx @@ -222,6 +222,13 @@ main (int argc, char* argv[]) parser->setFeature (XMLUni::fgXercesSchema, true); parser->setFeature (XMLUni::fgXercesSchemaFullChecking, false); + // Xerces-C++ 3.1.0 is the first version with working multi import + // support. + // +#if _XERCES_VERSION >= 30100 + parser->setFeature (XMLUni::fgXercesHandleMultipleImports, true); +#endif + parser->loadGrammar ("test.xsd", Grammar::SchemaGrammarType, true); parser->setFeature (XMLUni::fgXercesUseCachedGrammarInParse, true); } diff --git a/examples/cxx/tree/caching/driver.cxx b/examples/cxx/tree/caching/driver.cxx index 5c3405a..015606f 100644 --- a/examples/cxx/tree/caching/driver.cxx +++ b/examples/cxx/tree/caching/driver.cxx @@ -84,12 +84,19 @@ main (int argc, char* argv[]) // conf->setParameter (XMLUni::fgDOMElementContentWhitespace, false); - // Enable/Disable validation. + // Enable validation. // conf->setParameter (XMLUni::fgDOMValidate, true); conf->setParameter (XMLUni::fgXercesSchema, true); conf->setParameter (XMLUni::fgXercesSchemaFullChecking, false); + // Xerces-C++ 3.1.0 is the first version with working multi import + // support. + // +#if _XERCES_VERSION >= 30100 + conf->setParameter (XMLUni::fgXercesHandleMultipleImports, true); +#endif + // Set error handler. // tree::error_handler eh; diff --git a/examples/cxx/tree/custom/comments/dom-parse.cxx b/examples/cxx/tree/custom/comments/dom-parse.cxx index 7ad6aa5..1ba62e5 100644 --- a/examples/cxx/tree/custom/comments/dom-parse.cxx +++ b/examples/cxx/tree/custom/comments/dom-parse.cxx @@ -68,6 +68,13 @@ parse (std::istream& is, const std::string& id, bool validate) conf->setParameter (XMLUni::fgXercesSchema, validate); conf->setParameter (XMLUni::fgXercesSchemaFullChecking, false); + // Xerces-C++ 3.1.0 is the first version with working multi import + // support. + // +#if _XERCES_VERSION >= 30100 + conf->setParameter (XMLUni::fgXercesHandleMultipleImports, true); +#endif + // We will release the DOM document ourselves. // conf->setParameter (XMLUni::fgXercesUserAdoptsDOMDocument, true); diff --git a/examples/cxx/tree/messaging/dom-parse.cxx b/examples/cxx/tree/messaging/dom-parse.cxx index d6ce204..e4bc6cc 100644 --- a/examples/cxx/tree/messaging/dom-parse.cxx +++ b/examples/cxx/tree/messaging/dom-parse.cxx @@ -68,6 +68,13 @@ parse (std::istream& is, const std::string& id, bool validate) conf->setParameter (XMLUni::fgXercesSchema, validate); conf->setParameter (XMLUni::fgXercesSchemaFullChecking, false); + // Xerces-C++ 3.1.0 is the first version with working multi import + // support. + // +#if _XERCES_VERSION >= 30100 + conf->setParameter (XMLUni::fgXercesHandleMultipleImports, true); +#endif + // We will release the DOM document ourselves. // conf->setParameter (XMLUni::fgXercesUserAdoptsDOMDocument, true); diff --git a/examples/cxx/tree/multiroot/dom-parse.cxx b/examples/cxx/tree/multiroot/dom-parse.cxx index 3a67626..2b57be0 100644 --- a/examples/cxx/tree/multiroot/dom-parse.cxx +++ b/examples/cxx/tree/multiroot/dom-parse.cxx @@ -68,6 +68,13 @@ parse (std::istream& is, const std::string& id, bool validate) conf->setParameter (XMLUni::fgXercesSchema, validate); conf->setParameter (XMLUni::fgXercesSchemaFullChecking, false); + // Xerces-C++ 3.1.0 is the first version with working multi import + // support. + // +#if _XERCES_VERSION >= 30100 + conf->setParameter (XMLUni::fgXercesHandleMultipleImports, true); +#endif + // We will release the DOM document ourselves. // conf->setParameter (XMLUni::fgXercesUserAdoptsDOMDocument, true); diff --git a/examples/cxx/tree/performance/parsing.cxx b/examples/cxx/tree/performance/parsing.cxx index fd27fb2..3997ea6 100644 --- a/examples/cxx/tree/performance/parsing.cxx +++ b/examples/cxx/tree/performance/parsing.cxx @@ -90,6 +90,13 @@ parsing (const char* file, unsigned long iter, bool validate) conf->setParameter (XMLUni::fgXercesSchema, true); conf->setParameter (XMLUni::fgXercesSchemaFullChecking, false); + // Xerces-C++ 3.1.0 is the first version with working multi import + // support. + // +#if _XERCES_VERSION >= 30100 + conf->setParameter (XMLUni::fgXercesHandleMultipleImports, true); +#endif + // If we are validating, pre-load and cache the schema. // parser->loadGrammar ("test.xsd", Grammar::SchemaGrammarType, true); diff --git a/examples/cxx/tree/streaming/parser.cxx b/examples/cxx/tree/streaming/parser.cxx index 1a0fa73..77fc6cc 100644 --- a/examples/cxx/tree/streaming/parser.cxx +++ b/examples/cxx/tree/streaming/parser.cxx @@ -99,6 +99,13 @@ parser_impl () parser_->setFeature (XMLUni::fgXercesValidationErrorAsFatal, true); parser_->setFeature (XMLUni::fgXercesSchemaFullChecking, false); + // Xerces-C++ 3.1.0 is the first version with working multi import + // support. + // +#if _XERCES_VERSION >= 30100 + parser_->setFeature (XMLUni::fgXercesHandleMultipleImports, true); +#endif + parser_->setErrorHandler (&error_proxy_); parser_->setContentHandler (this); } diff --git a/examples/cxx/tree/xpath/dom-parse.cxx b/examples/cxx/tree/xpath/dom-parse.cxx index 84ff0af..82e87b6 100644 --- a/examples/cxx/tree/xpath/dom-parse.cxx +++ b/examples/cxx/tree/xpath/dom-parse.cxx @@ -63,6 +63,13 @@ parse (std::istream& is, conf->setParameter (XMLUni::fgXercesSchema, validate); conf->setParameter (XMLUni::fgXercesSchemaFullChecking, false); + // Xerces-C++ 3.1.0 is the first version with working multi import + // support. + // +#if _XERCES_VERSION >= 30100 + conf->setParameter (XMLUni::fgXercesHandleMultipleImports, true); +#endif + // We will release the DOM document ourselves. // conf->setParameter (XMLUni::fgXercesUserAdoptsDOMDocument, true); diff --git a/libxsd/xsd/cxx/parser/xerces/elements.hxx b/libxsd/xsd/cxx/parser/xerces/elements.hxx index 9d79e61..a44cf50 100644 --- a/libxsd/xsd/cxx/parser/xerces/elements.hxx +++ b/libxsd/xsd/cxx/parser/xerces/elements.hxx @@ -48,7 +48,7 @@ namespace xsd static const unsigned long dont_initialize = 0x00000002; // Disable handling of subsequent imports for the same namespace - // in Xerces-C++ 3-series. + // in Xerces-C++ 3.1.0 and later. // static const unsigned long no_multiple_imports = 0x00000004; diff --git a/libxsd/xsd/cxx/parser/xerces/elements.txx b/libxsd/xsd/cxx/parser/xerces/elements.txx index e09ffc5..62376d0 100644 --- a/libxsd/xsd/cxx/parser/xerces/elements.txx +++ b/libxsd/xsd/cxx/parser/xerces/elements.txx @@ -607,7 +607,10 @@ namespace xsd sax->setFeature (XMLUni::fgSAX2CoreValidation, true); sax->setFeature (XMLUni::fgXercesSchema, true); -#if _XERCES_VERSION >= 30000 + // Xerces-C++ 3.1.0 is the first version with working multi import + // support. + // +#if _XERCES_VERSION >= 30100 if (!(f & flags::no_multiple_imports)) sax->setFeature (XMLUni::fgXercesHandleMultipleImports, true); #endif diff --git a/libxsd/xsd/cxx/xml/dom/parsing-source.txx b/libxsd/xsd/cxx/xml/dom/parsing-source.txx index ae7ceea..741dedc 100644 --- a/libxsd/xsd/cxx/xml/dom/parsing-source.txx +++ b/libxsd/xsd/cxx/xml/dom/parsing-source.txx @@ -155,8 +155,13 @@ namespace xsd conf->setParameter (XMLUni::fgDOMValidate, true); conf->setParameter (XMLUni::fgXercesSchema, true); + // Xerces-C++ 3.1.0 is the first version with working multi import + // support. + // +#if _XERCES_VERSION >= 30100 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 @@ -348,8 +353,13 @@ namespace xsd conf->setParameter (XMLUni::fgDOMValidate, true); conf->setParameter (XMLUni::fgXercesSchema, true); + // Xerces-C++ 3.1.0 is the first version with working multi import + // support. + // +#if _XERCES_VERSION >= 30100 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 -- cgit v1.1