From 56a73c1c7b1e63f1ff1717b25a76ebd480594d5a Mon Sep 17 00:00:00 2001 From: Scott Cantor Date: Wed, 21 Dec 2011 19:33:37 +0000 Subject: [PATCH] Move catalog handling to parser API from config API. --- xmltooling/XMLToolingConfig.cpp | 15 +++------------ xmltooling/XMLToolingConfig.h | 1 + xmltooling/util/ParserPool.cpp | 13 +++++++++++++ xmltooling/util/ParserPool.h | 17 +++++++++++++++-- 4 files changed, 32 insertions(+), 14 deletions(-) diff --git a/xmltooling/XMLToolingConfig.cpp b/xmltooling/XMLToolingConfig.cpp index bcd6eba..6760d9e 100644 --- a/xmltooling/XMLToolingConfig.cpp +++ b/xmltooling/XMLToolingConfig.cpp @@ -55,9 +55,7 @@ #endif #include -#include #include -#include #if defined(XMLTOOLING_LOG4SHIB) # include @@ -423,16 +421,9 @@ bool XMLToolingInternalConfig::init() m_parserPool=new ParserPool(); m_validatingPool=new ParserPool(true,true); - // Load catalogs from path. - if (!catalog_path.empty()) { - boost::tokenizer< char_separator > catpaths(catalog_path, char_separator(PATH_SEPARATOR_STR)); - for_each( - catpaths.begin(), catpaths.end(), - // Call loadCatalog with an inner call to s->c_str() on each entry. - boost::bind(static_cast(&ParserPool::loadCatalog), - m_validatingPool, boost::bind(&string::c_str,_1)) - ); - } + // Load catalogs from deprecated path setting. + if (!catalog_path.empty()) + m_validatingPool->loadCatalogs(catalog_path.c_str()); // default registrations XMLObjectBuilder::registerDefaultBuilder(new UnknownElementBuilder()); diff --git a/xmltooling/XMLToolingConfig.h b/xmltooling/XMLToolingConfig.h index 928ce71..76d81fc 100644 --- a/xmltooling/XMLToolingConfig.h +++ b/xmltooling/XMLToolingConfig.h @@ -250,6 +250,7 @@ namespace xmltooling { void setURLEncoder(URLEncoder* urlEncoder); /** + * @deprecated * List of catalog files to load into validating parser pool at initialization time. *

Like other path settings, the separator depends on the platform * (semicolon on Windows, colon otherwise). diff --git a/xmltooling/util/ParserPool.cpp b/xmltooling/util/ParserPool.cpp index 5e44c28..a195dd7 100644 --- a/xmltooling/util/ParserPool.cpp +++ b/xmltooling/util/ParserPool.cpp @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -236,6 +237,18 @@ bool ParserPool::loadSchema(const XMLCh* nsURI, const XMLCh* pathname) return true; } +bool ParserPool::loadCatalogs(const char* pathnames) +{ + boost::tokenizer< char_separator > catpaths(string(pathnames), char_separator(PATH_SEPARATOR_STR)); + for_each( + catpaths.begin(), catpaths.end(), + // Call loadCatalog with an inner call to s->c_str() on each entry. + boost::bind(static_cast(&ParserPool::loadCatalog), + boost::ref(this), boost::bind(&string::c_str, _1)) + ); + return catpaths.begin() != catpaths.end(); +} + bool ParserPool::loadCatalog(const char* pathname) { auto_ptr_XMLCh temp(pathname); diff --git a/xmltooling/util/ParserPool.h b/xmltooling/util/ParserPool.h index 93c2af4..1fd127d 100644 --- a/xmltooling/util/ParserPool.h +++ b/xmltooling/util/ParserPool.h @@ -107,15 +107,28 @@ namespace xmltooling { xercesc::DOMDocument* parse(std::istream& is); /** + * Load OASIS catalog files to map schema namespace URIs to filenames. + * + *

This does not provide real catalog support; only the <uri> element + * is supported to map from a namespace URI to a relative path or file:// URI. + * + *

Multiple files can be specified using a platform-specific path delimiter. + * + * @param pathname path to one or more catalog files + * @return true iff the catalogs were successfully processed + */ + bool loadCatalogs(const char* pathnames); + + /** * Load an OASIS catalog file to map schema namespace URIs to filenames. * - * This does not provide real catalog support; only the <uri> element + *

This does not provide real catalog support; only the <uri> element * is supported to map from a namespace URI to a relative path or file:// URI. * * @param pathname path to a catalog file * @return true iff the catalog was successfully processed */ - bool loadCatalog(const char* pathname); + bool loadCatalog(const char* pathnames); /** * Load an OASIS catalog file to map schema namespace URIs to filenames. -- 2.1.4