From: Marc Cromme Date: Thu, 6 Jul 2006 12:42:21 +0000 (+0000) Subject: bug #504 fix X-Git-Tag: ZEBRA.2.0.0~24 X-Git-Url: http://jsfdemo.indexdata.com/cgi-bin?a=commitdiff_plain;h=c23dcf8e79596d2ae1fc05596e1d60ed318962e7;p=idzebra-moved-to-github.git bug #504 fix The GRS module now ignores any previously existing GRS subtree of the form ... both under indexing and retrieval of records. This is to facilitate remote update of GRS records, which have been augmented by zebra-internal meta data info, such that this part is not appended twice. The local storage is still including the GRS subtree, but it is not indexed any more, and stripped before retrieval, i.e. for all practical purposes it is not existent. --- diff --git a/data1/Makefile.am b/data1/Makefile.am index acff185..3aba070 100644 --- a/data1/Makefile.am +++ b/data1/Makefile.am @@ -1,10 +1,11 @@ -## $Id: Makefile.am,v 1.7 2006-07-05 15:03:45 adam Exp $ +## $Id: Makefile.am,v 1.8 2006-07-06 12:42:21 marc Exp $ noinst_LTLIBRARIES=libidzebra-data1.la libidzebra_data1_la_SOURCES = d1_handle.c d1_read.c d1_attset.c d1_tagset.c \ d1_absyn.c d1_grs.c d1_sutrs.c d1_varset.c d1_espec.c d1_doespec.c d1_map.c \ - d1_marc.c d1_write.c d1_expout.c d1_sumout.c d1_soif.c d1_prtree.c d1_if.c + d1_marc.c d1_write.c d1_expout.c d1_sumout.c d1_soif.c d1_prtree.c d1_if.c \ + d1_utils.c AM_CPPFLAGS=-I$(top_srcdir)/include $(YAZINC) diff --git a/data1/d1_utils.c b/data1/d1_utils.c new file mode 100644 index 0000000..396d1db --- /dev/null +++ b/data1/d1_utils.c @@ -0,0 +1,125 @@ +/* $Id: d1_utils.c,v 1.1 2006-07-06 12:42:21 marc Exp $ + Copyright (C) 1995-2006 + Index Data ApS + +This file is part of the Zebra server. + +Zebra is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 2, or (at your option) any later +version. + +Zebra is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Zebra; see the file LICENSE.zebra. If not, write to the +Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. +*/ + +#include +#include +#include + +#include +#include + + +void data1_remove_node (data1_handle dh, data1_node *n) +{ + fprintf (stdout, "REMOVE tag %s \n", n->u.tag.tag); + /* n is first childen */ + if(n->parent->child == n){ + n->parent->child = n->next; + + /* n is the only child */ + if(! n->next){ + n->parent->last_child = 0; + } + } + /* n is one of the following childrens */ + else { + data1_node * before; + + /* need to find sibling before me */ + before = n->parent->child; + while (before->next != n) + before = before->next; + + before->next = n->next; + + /* n is last child of many */ + if ( n->parent->last_child == n){ + n->parent->last_child = before; + } + } + /* break pointers to root, parent and following siblings */ + n->parent = 0; + n->root = 0; + n->next = 0; +} + +void data1_remove_idzebra_subtree (data1_handle dh, data1_node *n) +{ + switch (n->which) + { + /* + case DATA1N_root: + break; + */ + case DATA1N_tag: + if (!strcmp(n->u.tag.tag, "idzebra")){ + if (n->u.tag.attributes){ + data1_xattr *xattr = n->u.tag.attributes; + + for (; xattr; xattr = xattr->next){ + if (!strcmp(xattr->name, "xmlns") + & !strcmp(xattr->value, + "http://www.indexdata.dk/zebra/")) + data1_remove_node (dh, n); + } + } + } + + break; + /* + case DATA1N_data: + break; + case DATA1N_comment: + break; + case DATA1N_preprocess: + break; + case DATA1N_variant: + break; + */ + default: + break; + } + if (n->child) + data1_remove_idzebra_subtree (dh, n->child); + if (n->next) + data1_remove_idzebra_subtree (dh, n->next); + /* + else + { + if (n->parent && n->parent->last_child != n) + fprintf(out, "%*sWARNING: last_child=%p != %p\n", level, "", + n->parent->last_child, n); + } + */ + +} + + + +/* + * Local variables: + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + * vim: shiftwidth=4 tabstop=8 expandtab + */ + diff --git a/include/idzebra/data1.h b/include/idzebra/data1.h index b09f3a1..51f138d 100644 --- a/include/idzebra/data1.h +++ b/include/idzebra/data1.h @@ -1,4 +1,4 @@ -/* $Id: data1.h,v 1.16 2006-07-06 11:40:24 adam Exp $ +/* $Id: data1.h,v 1.17 2006-07-06 12:42:22 marc Exp $ Copyright (C) 1995-2006 Index Data ApS @@ -371,6 +371,9 @@ YAZ_EXPORT data1_node *data1_read_nodex (data1_handle dh, NMEM m, YAZ_EXPORT data1_node *data1_read_record(data1_handle dh, int (*rf)(void *, char *, size_t), void *fh, NMEM m); + +YAZ_EXPORT void data1_remove_node (data1_handle dh, data1_node *n); +YAZ_EXPORT void data1_remove_idzebra_subtree (data1_handle dh, data1_node *n); YAZ_EXPORT data1_tag *data1_gettagbynum(data1_handle dh, data1_tagset *s, int type, int value); diff --git a/index/recgrs.c b/index/recgrs.c index cd11eda..8a31f3c 100644 --- a/index/recgrs.c +++ b/index/recgrs.c @@ -1,4 +1,4 @@ -/* $Id: recgrs.c,v 1.2 2006-07-06 11:40:25 adam Exp $ +/* $Id: recgrs.c,v 1.3 2006-07-06 12:42:22 marc Exp $ Copyright (C) 1995-2006 Index Data ApS @@ -937,6 +937,8 @@ int grs_extract_tree(struct recExtractCtrl *p, data1_node *n) } (*p->init)(p, &wrd); + /* data1_pr_tree(p->dh, n, stdout); */ + return dumpkeys(n, p, &wrd); } @@ -980,6 +982,9 @@ static int grs_extract_sub(void *clientData, struct recExtractCtrl *p, /* ensure our data1 tree is UTF-8 */ data1_iconv (p->dh, mem, n, "UTF-8", data1_get_encoding(p->dh, n)); + + data1_remove_idzebra_subtree (p->dh, n); + #if 0 data1_pr_tree (p->dh, n, stdout); #endif @@ -1164,6 +1169,8 @@ int zebra_grs_retrieve(void *clientData, struct recRetrieveCtrl *p, } data1_concat_text(p->dh, mem, node); + data1_remove_idzebra_subtree (p->dh, node); + #if 0 data1_pr_tree (p->dh, node, stdout); #endif diff --git a/test/filters/Makefile.am b/test/filters/Makefile.am index 8dd2236..fd7aa60 100644 --- a/test/filters/Makefile.am +++ b/test/filters/Makefile.am @@ -1,13 +1,14 @@ -# $Id: Makefile.am,v 1.3 2006-07-03 14:27:21 adam Exp $ +# $Id: Makefile.am,v 1.4 2006-07-06 12:42:23 marc Exp $ -check_PROGRAMS = text grs.xml grs.marc +check_PROGRAMS = text grs.xml grs.xml.idzebra grs.marc TESTS = $(check_PROGRAMS) -EXTRA_DIST = zebra.cfg record.xml record.mrc +EXTRA_DIST = zebra.cfg record.xml record-idzebra.xml record.mrc text_SOURCES = text.c grs_xml_SOURCES = grs.xml.c +grs_xml_idzebra_SOURCES = grs.xml.idzebra.c grs_marc_SOURCES = grs.marc.c AM_CPPFLAGS = -I$(top_srcdir)/include $(YAZINC)