add support for XInclude in the main configuration file
authorSven-S. Porst <porst@sub.uni-goettingen.de>
Mon, 1 Oct 2012 16:10:44 +0000 (18:10 +0200)
committerAdam Dickmeiss <adam@indexdata.dk>
Mon, 3 Feb 2014 12:56:42 +0000 (13:56 +0100)
src/pazpar2_config.c

index 92717e2..a4503b7 100644 (file)
@@ -26,6 +26,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
 #include <libxml/parser.h>
 #include <libxml/tree.h>
+#include <libxml/xinclude.h>
 
 #include <yaz/yaz-util.h>
 #include <yaz/nmem.h>
@@ -1232,7 +1233,10 @@ static int parse_config(struct conf_config *config, xmlNode *root)
 
 struct conf_config *config_create(const char *fname, int verbose)
 {
-    xmlDoc *doc = xmlParseFile(fname);
+    xmlDoc *doc = xmlReadFile(fname,
+                              NULL,
+                              XML_PARSE_XINCLUDE + XML_PARSE_NOBLANKS
+                              + XML_PARSE_NSCLEAN + XML_PARSE_NONET );
     xmlNode *n;
     const char *p;
     int r;
@@ -1248,6 +1252,14 @@ struct conf_config *config_create(const char *fname, int verbose)
         return 0;
     }
 
+    // Perform XInclude.
+    r = xmlXIncludeProcess(doc);
+    if (r == -1)
+    {
+        yaz_log(YLOG_FATAL, "XInclude processing failed");
+        return 0;
+    }
+
     config->nmem = nmem;
     config->servers = 0;
     config->no_threads = 0;