Implement XInclude for XML configuration file(s).
authorAdam Dickmeiss <adam@indexdata.dk>
Tue, 9 Nov 2004 14:24:22 +0000 (14:24 +0000)
committerAdam Dickmeiss <adam@indexdata.dk>
Tue, 9 Nov 2004 14:24:22 +0000 (14:24 +0000)
NEWS
etc/Makefile.am
etc/config.xml
etc/explain.xml [new file with mode: 0644]
src/yaz-proxy-config.cpp

diff --git a/NEWS b/NEWS
index d1e2c3d..a637fac 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,5 @@
+Implement XInclude for configuration file(s).
+
 Fixed bug #189: Bad authenticated session transfer.
 
 New config element "authentication" which specifies authentication
index 4aba48b..7904c47 100644 (file)
@@ -1,4 +1,4 @@
-# $Id: Makefile.am,v 1.3 2004-04-23 16:10:24 adam Exp $
+# $Id: Makefile.am,v 1.4 2004-11-09 14:24:22 adam Exp $
 
 proxydatadir=$(datadir)/yazproxy
 proxydata_DATA = \
@@ -9,6 +9,7 @@ proxydata_DATA = \
  MARC21slim2RDFDC.xsl \
  MARC21slimUtils.xsl \
  config.xml \
+ explain.xml \
  voyager.xml \
  pqf.properties \
  yazproxy.xsd \
index 6bc751c..da92156 100644 (file)
@@ -1,6 +1,7 @@
 <?xml version="1.0"?>
-<!-- $Id: config.xml,v 1.6 2004-10-23 23:12:23 adam Exp $ -->
+<!-- $Id: config.xml,v 1.7 2004-11-09 14:24:22 adam Exp $ -->
 <proxy xmlns="http://indexdata.dk/yazproxy/schema/0.8/"
+ xmlns:xi="http://www.w3.org/2001/XInclude"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://indexdata.dk/yazproxy/schema/0.8/ yazproxy.xsd"
 >
     <syntax type="xml" marcxml="1"/>
     <syntax type="*" error="238"/>
     <preinit>0</preinit>
-    <explain xmlns="http://explain.z3950.org/dtd/2.0/">
-       <serverInfo>
-       <host>localhost</host>
-       <port>9000</port>
-       <database>gils</database>
-       </serverInfo>
-    </explain>
+    <xi:include href="explain.xml"/>
     <cql2rpn>pqf.properties</cql2rpn>
     <authentication>adam/x</authentication>
   </target>
diff --git a/etc/explain.xml b/etc/explain.xml
new file mode 100644 (file)
index 0000000..4db3c6b
--- /dev/null
@@ -0,0 +1,11 @@
+<explain xmlns="http://explain.z3950.org/dtd/2.0/">
+  <serverInfo>
+    <host>localhost</host>
+    <port>9000</port>
+    <database>gils</database>
+  </serverInfo>
+  <databaseInfo>
+    <title>My Database</title>
+    <description>My database description</description>
+  </databaseInfo>
+</explain>
index 0486e73..c05724e 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: yaz-proxy-config.cpp,v 1.8 2004-10-23 23:12:24 adam Exp $
+/* $Id: yaz-proxy-config.cpp,v 1.9 2004-11-09 14:24:22 adam Exp $
    Copyright (c) 1998-2004, Index Data.
 
 This file is part of the yaz-proxy.
@@ -26,6 +26,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #if HAVE_XSLT
 #include <libxml/parser.h>
 #include <libxml/tree.h>
+#include <libxml/xinclude.h>
 #include <libxslt/xsltutils.h>
 #include <libxslt/transform.h>
 #endif
@@ -95,6 +96,10 @@ int Yaz_ProxyConfig::read_xml(const char *fname)
        yaz_log(LOG_WARN, "Config file %s not found or parse error", fname);
        return -1;  // no good
     }
+    int noSubstitutions = xmlXIncludeProcess(ndoc);
+    if (noSubstitutions == -1)
+       yaz_log(LOG_WARN, "XInclude processing failed on config %s", fname);
+
     xmlNodePtr proxyPtr = xmlDocGetRootElement(ndoc);
     if (!proxyPtr || proxyPtr->type != XML_ELEMENT_NODE ||
        strcmp((const char *) proxyPtr->name, "proxy"))