Support for a catalog path.
authorScott Cantor <cantor.2@osu.edu>
Wed, 13 Sep 2006 21:11:20 +0000 (21:11 +0000)
committerScott Cantor <cantor.2@osu.edu>
Wed, 13 Sep 2006 21:11:20 +0000 (21:11 +0000)
xmltooling/XMLToolingConfig.cpp
xmltooling/XMLToolingConfig.h
xmltooling/internal.h
xmltoolingtest/xmltoolingtest.h

index e248f6a..a7cbc42 100644 (file)
@@ -161,6 +161,22 @@ bool XMLToolingInternalConfig::init()
         m_parserPool=new ParserPool();
         m_validatingPool=new ParserPool(true,true);
         m_lock=xercesc::XMLPlatformUtils::makeMutex();
+        
+        // Load catalogs from path.
+        if (!catalog_path.empty()) {
+            char* catpath=strdup(catalog_path.c_str());
+            char* sep=NULL;
+            char* start=catpath;
+            while (start && *start) {
+                sep=strchr(start,PATH_SEPARATOR_CHAR);
+                if (sep)
+                    *sep=0;
+                auto_ptr_XMLCh temp(start);
+                m_validatingPool->loadCatalog(temp.get());
+                start = sep ? sep + 1 : NULL;
+            }
+            free(catpath);
+        }
 
         // default registrations
         XMLObjectBuilder::registerDefaultBuilder(new UnknownElementBuilder());
index 4b5ff2c..f60a06a 100644 (file)
@@ -125,6 +125,13 @@ namespace xmltooling {
          * @return reference to a validating parser pool.\r
          */\r
         virtual ParserPool& getValidatingParser() const=0;\r
+        \r
+        /**\r
+         * Set to catalog files to load into validating parser pool at initialization time.\r
+         * Like other path settings, the separator depends on the platform\r
+         * (semicolon on Windows, colon otherwise). \r
+         */\r
+        std::string catalog_path;\r
 \r
 #ifndef XMLTOOLING_NO_XMLSEC\r
         /**\r
index f4c51bf..b222ef4 100644 (file)
 
 #define XMLTOOLING_LOGCAT "XMLTooling"
 
+// Macros for path and directory separators.
+#if defined __CYGWIN32__ && !defined __CYGWIN__
+   /* For backwards compatibility with Cygwin b19 and
+      earlier, we define __CYGWIN__ here, so that
+      we can rely on checking just for that macro. */
+#  define __CYGWIN__  __CYGWIN32__
+#endif
+
+#if defined _WIN32 && !defined __CYGWIN__
+   /* Use Windows separators on all _WIN32 defining
+      environments, except Cygwin. */
+#  define DIR_SEPARATOR_CHAR        '\\'
+#  define DIR_SEPARATOR_STR         "\\"
+#  define PATH_SEPARATOR_CHAR       ';'
+#  define PATH_SEPARATOR_STR        ";"
+#endif
+#ifndef DIR_SEPARATOR_CHAR
+   /* Assume that not having this is an indicator that all
+      are missing. */
+#  define DIR_SEPARATOR_CHAR        '/'
+#  define DIR_SEPARATOR_STR         "/"
+#  define PATH_SEPARATOR_CHAR       ':'
+#  define PATH_SEPARATOR_STR        ":"
+#endif /* !DIR_SEPARATOR_CHAR */
+
 namespace xmltooling {
     
     /// @cond OFF
index fe1e867..6507143 100644 (file)
@@ -30,13 +30,15 @@ class ToolingFixture : public CxxTest::GlobalFixture
 public:\r
     bool setUpWorld() {\r
         XMLToolingConfig::getConfig().log_config();\r
-        if (!XMLToolingConfig::getConfig().init())\r
-            return false;\r
+\r
         if (getenv("XMLTOOLINGTEST_DATA"))\r
             data_path=std::string(getenv("XMLTOOLINGTEST_DATA")) + "/";\r
-        std::string catpath=data_path + "catalog.xml";\r
-        auto_ptr_XMLCh temp(catpath.c_str());\r
-        return XMLToolingConfig::getConfig().getValidatingParser().loadCatalog(temp.get());\r
+        XMLToolingConfig::getConfig().catalog_path = data_path + "catalog.xml";\r
+\r
+        if (!XMLToolingConfig::getConfig().init())\r
+            return false;\r
+        \r
+        return true;\r
     }\r
     bool tearDownWorld() {\r
         XMLToolingConfig::getConfig().term();\r