Same fname scheme for mmap+xslt
authorAdam Dickmeiss <adam@indexdata.dk>
Tue, 29 Sep 2009 13:46:01 +0000 (15:46 +0200)
committerAdam Dickmeiss <adam@indexdata.dk>
Tue, 29 Sep 2009 13:46:01 +0000 (15:46 +0200)
src/logic.c
src/pazpar2_config.c
src/pazpar2_config.h

index 2d03517..8c2d070 100644 (file)
@@ -350,17 +350,21 @@ static int prepare_map(struct session *se, struct session_database *sdb)
         nmem_strsplit(se->session_nmem, ",", s, &stylesheets, &num);
         for (i = 0; i < num; i++)
         {
+            WRBUF fname = conf_get_fname(se->service, stylesheets[i]);
+            
             (*m) = nmem_malloc(se->session_nmem, sizeof(**m));
             (*m)->next = 0;
+            
             // XSLT
             if (!strcmp(&stylesheets[i][strlen(stylesheets[i])-4], ".xsl")) 
             {    
                 (*m)->marcmap = NULL;
-                if (!((*m)->stylesheet = conf_load_stylesheet(se->service, stylesheets[i])))
+                if (!((*m)->stylesheet =
+                      xsltParseStylesheetFile((xmlChar *) wrbuf_cstr(fname))))
                 {
                     yaz_log(YLOG_FATAL|YLOG_ERRNO, "Unable to load stylesheet: %s",
                             stylesheets[i]);
+                    wrbuf_destroy(fname);
                     return -1;
                 }
             }
@@ -368,14 +372,15 @@ static int prepare_map(struct session *se, struct session_database *sdb)
             else if (!strcmp(&stylesheets[i][strlen(stylesheets[i])-5], ".mmap"))
             {
                 (*m)->stylesheet = NULL;
-               if (!((*m)->marcmap = marcmap_load(stylesheets[i], se->session_nmem)))
+                if (!((*m)->marcmap = marcmap_load(wrbuf_cstr(fname), se->session_nmem)))
                 {
                     yaz_log(YLOG_FATAL|YLOG_ERRNO, "Unable to load marcmap: %s",
                             stylesheets[i]);
+                    wrbuf_destroy(fname);
                     return -1;
                 }
             }
-
+            wrbuf_destroy(fname);
             m = &(*m)->next;
         }
     }
index 4762aa5..60f1585 100644 (file)
@@ -26,9 +26,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
 #include <libxml/parser.h>
 #include <libxml/tree.h>
-#include <libxslt/xslt.h>
-#include <libxslt/transform.h>
-#include <libxslt/xsltutils.h>
 
 #include <yaz/yaz-util.h>
 #include <yaz/nmem.h>
@@ -822,17 +819,13 @@ static struct conf_server *server_create(struct conf_config *config,
     return server;
 }
 
-xsltStylesheet *conf_load_stylesheet(struct conf_service *service,
-                                     const char *fname)
+WRBUF conf_get_fname(struct conf_service *service, const char *fname)
 {
     struct conf_config *config = service->server->config;
     WRBUF w = wrbuf_alloc();
-    xsltStylesheet *s;
 
     conf_dir_path(config, w, fname);
-    s = xsltParseStylesheetFile((xmlChar *) wrbuf_cstr(w));
-    wrbuf_destroy(w);
-    return s;
+    return w;
 }
 
 static struct conf_targetprofiles *parse_targetprofiles(NMEM nmem,
index 1282cd3..ab0c46a 100644 (file)
@@ -22,7 +22,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
 #include <libxslt/xslt.h>
 #include <libxslt/transform.h>
-#include <libxslt/xsltutils.h>
 
 #include <yaz/nmem.h>
 #include "charsets.h"
@@ -155,9 +154,6 @@ struct conf_targetprofiles
 
 struct conf_config *config_create(const char *fname, int verbose);
 void config_destroy(struct conf_config *config);
-xsltStylesheet *conf_load_stylesheet(struct conf_service *service,
-                                     const char *fname);
-
 void config_start_databases(struct conf_config *config);
 
 struct conf_service *locate_service(struct conf_server *server,
@@ -173,6 +169,8 @@ int config_start_listeners(struct conf_config *conf,
 
 void config_stop_listeners(struct conf_config *conf);
 
+WRBUF conf_get_fname(struct conf_service *service, const char *fname);
+
 #endif
 
 /*