From c8a333d48c42e2a51f43fd42ef79e23d40a565a7 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Mon, 2 Dec 2002 16:55:14 +0000 Subject: [PATCH] Directive systag. --- CHANGELOG | 5 +++++ data1/d1_absyn.c | 38 ++++++++++++++++++++++++++++++++++++-- examples/zthes/Makefile | 4 ++-- examples/zthes/Zthes.abs | 1 + examples/zthes/zebra.cfg | 3 +-- include/data1.h | 11 +++++++++-- recctrl/recgrs.c | 23 +++++++++++++---------- tab/gils.abs | 4 +++- 8 files changed, 70 insertions(+), 19 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 7a40824..931bdb7 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,9 @@ +New .abs directive, systag, that control where to put retrieval +information. The directive takes two arguments: system tag, actual tag. +System tag is one of : rank, sysno, size with the default actual +rank, localControlNumber, size . + --- 1.3.4 2002/11/26 Perl Filter and Perl API. By Peter Popovics. diff --git a/data1/d1_absyn.c b/data1/d1_absyn.c index 1cee7f6..49f3e5d 100644 --- a/data1/d1_absyn.c +++ b/data1/d1_absyn.c @@ -1,4 +1,4 @@ -/* $Id: d1_absyn.c,v 1.2 2002-10-22 13:19:50 adam Exp $ +/* $Id: d1_absyn.c,v 1.3 2002-12-02 16:55:14 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002 Index Data Aps @@ -31,6 +31,12 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA #define D1_MAX_NESTING 128 +struct data1_systag { + char *name; + char *value; + struct data1_systag *next; +}; + struct data1_absyn_cache_info { char *name; @@ -293,6 +299,16 @@ static int parse_termlists (data1_handle dh, data1_termlist ***tpp, return 0; } +const char *data1_systag_lookup(data1_absyn *absyn, const char *tag, + const char *default_value) +{ + struct data1_systag *p = absyn->systags; + for (; p; p = p->next) + if (!strcmp(p->name, tag)) + return p->value; + return default_value; +} + data1_absyn *data1_read_absyn (data1_handle dh, const char *file, int file_must_exist) { @@ -306,6 +322,7 @@ data1_absyn *data1_read_absyn (data1_handle dh, const char *file, data1_termlist *all = 0; data1_attset_child **attset_childp; data1_tagset **tagset_childp; + struct data1_systag **systagsp; int level = 0; int lineno = 0; int argc; @@ -324,6 +341,8 @@ data1_absyn *data1_read_absyn (data1_handle dh, const char *file, res->tagset = 0; res->encoding = 0; res->enable_xpath_indexing = (f ? 0 : 1); + res->systags = 0; + systagsp = &res->systags; tagset_childp = &res->tagset; res->attset = data1_empty_attset (dh); @@ -336,7 +355,6 @@ data1_absyn *data1_read_absyn (data1_handle dh, const char *file, maptabp = &res->maptabs; res->marc = 0; marcp = &res->marc; - res->sub_elements = NULL; res->main_elements = NULL; @@ -692,6 +710,21 @@ data1_absyn *data1_read_absyn (data1_handle dh, const char *file, } res->encoding = nmem_strdup (data1_nmem_get(dh), argv[1]); } + else if (!strcmp(cmd, "systag")) + { + struct data1_systag *st; + if (argc != 3) + { + yaz_log(LOG_WARN, "%s:%d: Bad # or args for systag", + file, lineno); + continue; + } + *systagsp = nmem_malloc (data1_nmem_get(dh), sizeof(**systagsp)); + + (*systagsp)->name = nmem_strdup(data1_nmem_get(dh), argv[1]); + (*systagsp)->value = nmem_strdup(data1_nmem_get(dh), argv[2]); + systagsp = &(*systagsp)->next; + } else { yaz_log(LOG_WARN, "%s:%d: Unknown directive '%s'", file, @@ -709,6 +742,7 @@ data1_absyn *data1_read_absyn (data1_handle dh, const char *file, res->main_elements = cur_elements->elements; fix_element_ref (dh, res, cur_elements->elements); } + *systagsp = 0; yaz_log (LOG_DEBUG, "%s: data1_read_absyn end", file); return res; } diff --git a/examples/zthes/Makefile b/examples/zthes/Makefile index 51e59ca..e78229d 100644 --- a/examples/zthes/Makefile +++ b/examples/zthes/Makefile @@ -1,6 +1,6 @@ recdA-0.mf: records/dino.xml - zebraidx init - zebraidx update records + ../../index/zebraidx init + ../../index/zebraidx update records records/dino.xml: tree2xml.pl dino.tree ./tree2xml.pl dino.tree > records/dino.xml diff --git a/examples/zthes/Zthes.abs b/examples/zthes/Zthes.abs index 5244150..4d610ba 100644 --- a/examples/zthes/Zthes.abs +++ b/examples/zthes/Zthes.abs @@ -3,6 +3,7 @@ tagset tagsetm-zthes.tag tagset tagsetg-zthes.tag tagset zthes.tag xpath enable +systag sysno none elm (1,14) termId ! elm (2,1) termName ! diff --git a/examples/zthes/zebra.cfg b/examples/zthes/zebra.cfg index eba87f0..48742e8 100644 --- a/examples/zthes/zebra.cfg +++ b/examples/zthes/zebra.cfg @@ -1,5 +1,4 @@ -# $Id: zebra.cfg,v 1.3 2002-12-02 15:19:12 mike Exp $ +# $Id: zebra.cfg,v 1.4 2002-12-02 16:55:14 adam Exp $ profilePath: .:../../tab recordType: grs.sgml -tagsysno: 0 attset: zthes.att diff --git a/include/data1.h b/include/data1.h index 571e37a..33958f9 100644 --- a/include/data1.h +++ b/include/data1.h @@ -1,4 +1,4 @@ -/* $Id: data1.h,v 1.2 2002-10-22 13:19:50 adam Exp $ +/* $Id: data1.h,v 1.3 2002-12-02 16:55:14 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002 Index Data Aps @@ -194,6 +194,9 @@ typedef struct data1_xattr { unsigned short what; /* DATA1I_text, .. see data1_node.u.data */ } data1_xattr; +#if 0 +typedef struct data1_absyn data1_absyn; +#else typedef struct data1_absyn { char *name; @@ -206,10 +209,11 @@ typedef struct data1_absyn data1_marctab *marc; data1_sub_elements *sub_elements; data1_element *main_elements; + struct data1_systag *systags; char *encoding; int enable_xpath_indexing; } data1_absyn; - +#endif /* * record data node (tag/data/variant) */ @@ -486,6 +490,9 @@ YAZ_EXPORT const char *data1_get_encoding (data1_handle dh, data1_node *n); YAZ_EXPORT int data1_is_xmlmode(data1_handle dh); +YAZ_EXPORT const char *data1_systag_lookup(data1_absyn *absyn, const char *tag, + const char *default_value); + YAZ_END_CDECL #endif diff --git a/recctrl/recgrs.c b/recctrl/recgrs.c index 0e44cf2..28ce920 100644 --- a/recctrl/recgrs.c +++ b/recctrl/recgrs.c @@ -1,4 +1,4 @@ -/* $Id: recgrs.c,v 1.69 2002-11-15 21:57:41 adam Exp $ +/* $Id: recgrs.c,v 1.70 2002-12-02 16:55:14 adam Exp $ Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002 Index Data Aps @@ -651,7 +651,7 @@ static int grs_retrieve(void *clientData, struct recRetrieveCtrl *p) int res, selected = 0; NMEM mem; struct grs_read_info gri; - char *tagname; + const char *tagname; struct grs_handlers *h = (struct grs_handlers *) clientData; int requested_schema = VAL_NONE; data1_marctab *marctab; @@ -689,16 +689,18 @@ static int grs_retrieve(void *clientData, struct recRetrieveCtrl *p) top = data1_get_root_tag (p->dh, node); logf (LOG_DEBUG, "grs_retrieve: size"); - if ((dnew = data1_mk_tag_data_wd(p->dh, top, "size", mem))) + tagname = data1_systag_lookup(node->u.root.absyn, "size", "size"); + if (tagname && + (dnew = data1_mk_tag_data_wd(p->dh, top, tagname, mem))) { dnew->u.data.what = DATA1I_text; dnew->u.data.data = dnew->lbuf; sprintf(dnew->u.data.data, "%d", p->recordSize); dnew->u.data.len = strlen(dnew->u.data.data); } - - tagname = res_get_def(p->res, "tagrank", "rank"); - if (strcmp(tagname, "0") && p->score >= 0 && + + tagname = data1_systag_lookup(node->u.root.absyn, "rank", "rank"); + if (tagname && p->score >= 0 && (dnew = data1_mk_tag_data_wd(p->dh, top, tagname, mem))) { logf (LOG_DEBUG, "grs_retrieve: %s", tagname); @@ -708,14 +710,15 @@ static int grs_retrieve(void *clientData, struct recRetrieveCtrl *p) dnew->u.data.len = strlen(dnew->u.data.data); } - tagname = res_get_def(p->res, "tagsysno", "localControlNumber"); - if (strcmp(tagname, "0") && p->localno > 0 && - (dnew = data1_mk_tag_data_wd(p->dh, top, tagname, mem))) + tagname = data1_systag_lookup(node->u.root.absyn, "sysno", + "localControlNumber"); + if (tagname && p->localno > 0 && + (dnew = data1_mk_tag_data_wd(p->dh, top, tagname, mem))) { logf (LOG_DEBUG, "grs_retrieve: %s", tagname); dnew->u.data.what = DATA1I_text; dnew->u.data.data = dnew->lbuf; - + sprintf(dnew->u.data.data, "%d", p->localno); dnew->u.data.len = strlen(dnew->u.data.data); } diff --git a/tab/gils.abs b/tab/gils.abs index 44e9348..da047a1 100644 --- a/tab/gils.abs +++ b/tab/gils.abs @@ -1,7 +1,7 @@ # This is the abstract syntax (and most of the top-level profile info) # for GILS version 2. # -# $Id: gils.abs,v 1.1 2002-10-22 12:51:09 adam Exp $ +# $Id: gils.abs,v 1.2 2002-12-02 16:55:14 adam Exp $ name gils reference GILS-schema @@ -20,6 +20,8 @@ esetname G gils-g.est esetname W gils-b.est # We don't really do bodyOfDisplay yet. esetname F @ +systag sysno none + #all Any elm (1,1) schemaIdentifier - -- 1.7.10.4