Move catalog handling to parser API from config API.
authorScott Cantor <cantor.2@osu.edu>
Wed, 21 Dec 2011 19:33:37 +0000 (19:33 +0000)
committerScott Cantor <cantor.2@osu.edu>
Wed, 21 Dec 2011 19:33:37 +0000 (19:33 +0000)
xmltooling/XMLToolingConfig.cpp
xmltooling/XMLToolingConfig.h
xmltooling/util/ParserPool.cpp
xmltooling/util/ParserPool.h

index bcd6eba..6760d9e 100644 (file)
@@ -55,9 +55,7 @@
 #endif
 
 #include <stdexcept>
-#include <boost/bind.hpp>
 #include <boost/ptr_container/ptr_vector.hpp>
-#include <boost/tokenizer.hpp>
 
 #if defined(XMLTOOLING_LOG4SHIB)
 # include <log4shib/PropertyConfigurator.hh>
@@ -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<char> > catpaths(catalog_path, char_separator<char>(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<bool (ParserPool::*)(const char*)>(&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());
index 928ce71..76d81fc 100644 (file)
@@ -250,6 +250,7 @@ namespace xmltooling {
         void setURLEncoder(URLEncoder* urlEncoder);
         
         /**
+         * @deprecated
          * List of catalog files to load into validating parser pool at initialization time.
          * <p>Like other path settings, the separator depends on the platform
          * (semicolon on Windows, colon otherwise). 
index 5e44c28..a195dd7 100644 (file)
@@ -39,6 +39,7 @@
 #include <functional>
 #include <boost/algorithm/string.hpp>
 #include <boost/bind.hpp>
+#include <boost/tokenizer.hpp>
 #include <xercesc/util/PlatformUtils.hpp>
 #include <xercesc/util/XMLUniDefs.hpp>
 #include <xercesc/sax/SAXException.hpp>
@@ -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<char> > catpaths(string(pathnames), char_separator<char>(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<bool (ParserPool::*)(const char*)>(&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);
index 93c2af4..1fd127d 100644 (file)
@@ -107,15 +107,28 @@ namespace xmltooling {
         xercesc::DOMDocument* parse(std::istream& is);
 
         /**
+         * Load OASIS catalog files to map schema namespace URIs to filenames.
+         *
+         * <p>This does not provide real catalog support; only the &lt;uri&gt; element
+         * is supported to map from a namespace URI to a relative path or file:// URI.
+         *
+         * <p>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 &lt;uri&gt; element
+         * <p>This does not provide real catalog support; only the &lt;uri&gt; 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.