From ab6726a5092819765b5f68723c040db17444a86d Mon Sep 17 00:00:00 2001 From: Sebastian Hammer Date: Fri, 22 Dec 2006 04:43:11 +0000 Subject: [PATCH] Added load of global stylesheet (temporary measure only) --- src/Makefile | 4 ++-- src/default.bib | 13 ------------- src/pazpar2.c | 28 +++++++++++++++++++++++++--- src/pazpar2.h | 5 +++++ 4 files changed, 32 insertions(+), 18 deletions(-) delete mode 100644 src/default.bib diff --git a/src/Makefile b/src/Makefile index 52e23c1..1f9b450 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,12 +1,12 @@ # ParaZ. Copyright (C) 2000-2004, Index Data ApS # All rights reserved. -# $Id: Makefile,v 1.1 2006-12-20 20:47:16 quinn Exp $ +# $Id: Makefile,v 1.2 2006-12-22 04:43:11 quinn Exp $ SHELL=/bin/sh CC=gcc -YAZCONF=yaz-config +YAZCONF=yaz/yaz-config YAZLIBS=`$(YAZCONF) --libs` YAZCFLAGS=`$(YAZCONF) --cflags` diff --git a/src/default.bib b/src/default.bib deleted file mode 100644 index 0a32b52..0000000 --- a/src/default.bib +++ /dev/null @@ -1,13 +0,0 @@ -# CCL field mappings -# $Id: default.bib,v 1.1 2006-12-20 20:48:07 quinn Exp $ -# -# The rule below is used when no fields are specified -term u=1016 t=l,r s=al - -# Rules for some BIB-1 fields -au u=1 s=al -ti u=4 s=al -su u=21 s=al -isbn u=7 -issn u=8 -date u=30 r=r diff --git a/src/pazpar2.c b/src/pazpar2.c index 2c4826f..84a94c2 100644 --- a/src/pazpar2.c +++ b/src/pazpar2.c @@ -1,4 +1,4 @@ -/* $Id: pazpar2.c,v 1.4 2006-12-21 04:27:48 quinn Exp $ */; +/* $Id: pazpar2.c,v 1.5 2006-12-22 04:43:11 quinn Exp $ */; #include #include @@ -17,6 +17,7 @@ #include #include #include +#include #include "pazpar2.h" #include "eventl.h" @@ -69,6 +70,7 @@ struct parameters global_parameters = 0, 0, 0, + 0, 0 }; @@ -675,6 +677,17 @@ static void ingest_records(struct client *cl, Z_Records *r) session_alert_watch(s, SESSION_WATCH_RECORDS); } +xsltStylesheetPtr load_stylesheet(const char *fname) +{ + xsltStylesheetPtr ret; + if (!(ret = xsltParseStylesheetFile((const xmlChar *) fname))) + { + yaz_log(YLOG_FATAL|YLOG_ERRNO, "Failed to load stylesheet %s", fname); + exit(1); + } + return ret; +} + static void do_presentResponse(IOCHAN i, Z_APDU *a) { struct connection *co = iochan_getdata(i); @@ -1261,6 +1274,9 @@ struct termlist_score **termlist(struct session *s, int *num) return termlist_highscore(s->termlist, num); } +#ifdef REPORT_NMEM +// conditional compilation by SH: This lead to a warning with currently installed +// YAZ header files on us1 void report_nmem_stats(void) { size_t in_use, is_free; @@ -1271,6 +1287,7 @@ void report_nmem_stats(void) yaz_log(YLOG_LOG, "nmem stat: use=%ld free=%ld", (long) in_use, (long) is_free); } +#endif struct record **show(struct session *s, int start, int *num, int *total, int *sumhits, NMEM nmem_show) @@ -1355,7 +1372,7 @@ int main(int argc, char **argv) yaz_log_init(YLOG_DEFAULT_LEVEL, "pazpar2", 0); - while ((ret = options("c:h:p:C:s:", argv, argc, &arg)) != -2) + while ((ret = options("x:c:h:p:C:s:", argv, argc, &arg)) != -2) { switch (ret) { case 'c': @@ -1375,6 +1392,9 @@ int main(int argc, char **argv) case 's': load_simpletargets(arg); break; + case 'x': + global_parameters.xsl = load_stylesheet(arg); + break; default: fprintf(stderr, "Usage: pazpar2\n" " -h [host:]port (REST protocol listener)\n" @@ -1392,7 +1412,9 @@ int main(int argc, char **argv) exit(1); } - global_parameters.ccl_filter = load_cclfile("default.bib"); + if (!global_parameters.xsl) + global_parameters.xsl = load_stylesheet("../etc/default.xsl"); + global_parameters.ccl_filter = load_cclfile("../etc/default.bib"); global_parameters.yaz_marc = yaz_marc_create(); yaz_marc_subfield_str(global_parameters.yaz_marc, "\t"); global_parameters.odr_in = odr_createmem(ODR_DECODE); diff --git a/src/pazpar2.h b/src/pazpar2.h index a15b68b..b2d3d95 100644 --- a/src/pazpar2.h +++ b/src/pazpar2.h @@ -5,10 +5,14 @@ struct record; #include +#include +#include + #include #include #include #include + #include "termlists.h" #include "relevance.h" #include "eventl.h" @@ -146,6 +150,7 @@ struct parameters { yaz_marc_t yaz_marc; ODR odr_out; ODR odr_in; + xsltStylesheetPtr xsl; }; struct hitsbytarget *hitsbytarget(struct session *s, int *count); -- 1.7.10.4