From: Marc Cromme Date: Tue, 13 Feb 2007 11:37:02 +0000 (+0000) Subject: facturized DOM XML indexing code out into function X-Git-Tag: ZEBRA.2.0.12~57 X-Git-Url: http://sru.miketaylor.org.uk/cgi-bin?a=commitdiff_plain;h=eec24169543303f147c70a5cf15f4c52169f5e2e;p=idzebra-moved-to-github.git facturized DOM XML indexing code out into function static void extract_doc_alvis(struct filter_info *tinfo, struct recExtractCtrl *recctr, xmlDocPtr doc) This is the function to be re-written using both PI and instructions, and also fixing the bug of index type 'p' and '0' chop-over of merged content. --- diff --git a/index/mod_dom.c b/index/mod_dom.c index 7335ca4..26ae1a7 100644 --- a/index/mod_dom.c +++ b/index/mod_dom.c @@ -1,4 +1,4 @@ -/* $Id: mod_dom.c,v 1.3 2007-02-12 13:24:31 marc Exp $ +/* $Id: mod_dom.c,v 1.4 2007-02-13 11:37:02 marc Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -847,14 +847,44 @@ static void index_record(struct filter_info *tinfo,struct recExtractCtrl *ctrl, yaz_log(YLOG_WARN, "dom filter: unknown record type '%s'", type_str); } - -static int extract_doc(struct filter_info *tinfo, struct filter_input *input, - struct recExtractCtrl *p, xmlDocPtr doc) + + +static void extract_doc_alvis(struct filter_info *tinfo, + struct recExtractCtrl *recctr, + xmlDocPtr doc) { - RecWord recWord; - const char *params[10]; + if (doc){ + RecWord recWord; + xmlChar *buf_out; + int len_out; + xmlNodePtr root_ptr; + + (*recctr->init)(recctr, &recWord); + + if (recctr->flagShowRecords){ + xmlDocDumpMemory(doc, &buf_out, &len_out); + fwrite(buf_out, len_out, 1, stdout); + xmlFree(buf_out); + } + root_ptr = xmlDocGetRootElement(doc); + if (root_ptr) + index_record(tinfo, recctr, root_ptr, &recWord); + else + yaz_log(YLOG_WARN, "No root for index XML record"); + } +} + + +static int convert_extract_doc(struct filter_info *tinfo, + struct filter_input *input, + struct recExtractCtrl *p, + xmlDocPtr doc) + +{ + /* RecWord recWord; */ xmlChar *buf_out; int len_out; + const char *params[10]; xsltStylesheetPtr last_xsp = 0; xmlDocPtr store_doc = 0; @@ -864,7 +894,7 @@ static int extract_doc(struct filter_info *tinfo, struct filter_input *input, /* input conversion */ perform_convert(tinfo, input->convert, params, &doc, 0); - (*p->init)(p, &recWord); + /* (*p->init)(p, &recWord); */ if (tinfo->store) { @@ -889,8 +919,13 @@ static int extract_doc(struct filter_info *tinfo, struct filter_input *input, /* extract conversion */ perform_convert(tinfo, tinfo->extract->convert, params, &doc, 0); + if (doc) { + + extract_doc_alvis(tinfo, p, doc); + + /* xmlNodePtr root_ptr; if (p->flagShowRecords) { @@ -905,8 +940,11 @@ static int extract_doc(struct filter_info *tinfo, struct filter_input *input, { yaz_log(YLOG_WARN, "No root for index XML record"); } + */ + xmlFreeDoc(doc); - } + } + return RECCTRL_EXTRACT_OK; } @@ -946,7 +984,7 @@ static int extract_xml_split(struct filter_info *tinfo, xmlDocSetRootElement(doc, ptr2); - return extract_doc(tinfo, input, p, doc); + return convert_extract_doc(tinfo, input, p, doc); } else { @@ -976,7 +1014,7 @@ static int extract_xml_full(struct filter_info *tinfo, { return RECCTRL_EXTRACT_ERROR_GENERIC; } - return extract_doc(tinfo, input, p, doc); + return convert_extract_doc(tinfo, input, p, doc); } else return RECCTRL_EXTRACT_EOF; @@ -1030,7 +1068,7 @@ static int extract_iso2709(struct filter_info *tinfo, yaz_marc_write_xml(input->u.marc.handle, &root_ptr, 0, 0, 0); rdoc = xmlNewDoc((const xmlChar*) "1.0"); xmlDocSetRootElement(rdoc, root_ptr); - return extract_doc(tinfo, input, p, rdoc); + return convert_extract_doc(tinfo, input, p, rdoc); } return RECCTRL_EXTRACT_OK; } diff --git a/test/xslt/dom-config-col.xml b/test/xslt/dom-config-col.xml index 923ca8a..39e7f0c 100644 --- a/test/xslt/dom-config-col.xml +++ b/test/xslt/dom-config-col.xml @@ -1,6 +1,7 @@ - + + diff --git a/test/xslt/dom-index.xsl b/test/xslt/dom-index.xsl index b372b81..82c7102 100644 --- a/test/xslt/dom-index.xsl +++ b/test/xslt/dom-index.xsl @@ -2,12 +2,17 @@ xmlns:m="http://www.loc.gov/MARC21/slim" exclude-result-prefixes="m" version="1.0"> - + + @@ -37,6 +42,8 @@ <xsl:value-of select="."/> + +