X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=index%2Fmod_dom.c;h=f369c68904ccf3734cdd0cc26b5e39af00d55459;hb=896b30853daabb6294afe8b0a2f74fa6d6e397d8;hp=1832b056f06391f4093c3e9bd9d8f0ee5175e414;hpb=30d8682ec25b5468a8158a7a457fe6ca8345d765;p=idzebra-moved-to-github.git diff --git a/index/mod_dom.c b/index/mod_dom.c index 1832b05..f369c68 100644 --- a/index/mod_dom.c +++ b/index/mod_dom.c @@ -1,4 +1,4 @@ -/* $Id: mod_dom.c,v 1.34 2007-04-07 22:18:46 adam Exp $ +/* $Id: mod_dom.c,v 1.41 2007-10-29 16:57:52 adam Exp $ Copyright (C) 1995-2007 Index Data ApS @@ -43,6 +43,7 @@ #include #include +#include /* DOM filter style indexing */ #define ZEBRA_DOM_NS "http://indexdata.com/zebra-2.0" @@ -726,7 +727,7 @@ static void index_value_of(struct filter_info *tinfo, { xmlChar *text = xmlNodeGetContent(node); size_t text_len = strlen((const char *)text); - + /* if there is no text, we do not need to proceed */ if (text_len) { @@ -776,15 +777,10 @@ static void index_value_of(struct filter_info *tinfo, } /* actually indexing the text given */ - dom_log(YLOG_DEBUG, tinfo, 0, - "INDEX '%s:%s' '%s'", - index ? (const char *) index : "null", - type ? (const char *) type : "null", - text ? (const char *) text : "null"); recword->index_name = (const char *)index; if (type && *type) - recword->index_type = *type; + recword->index_type = (const char *) type; /* writing debug out */ if (extctr->flagShowRecords) @@ -794,10 +790,6 @@ static void index_value_of(struct filter_info *tinfo, type ? (const char *) type : "null", text ? (const char *) text : "null"); - /* actually indexing the text given */ - recword->index_name = (const char *)index; - if (type && *type) - recword->index_type = *type; (extctr->tokenAdd)(recword); /* eat whitespaces */ @@ -1089,9 +1081,25 @@ static int convert_extract_doc(struct filter_info *tinfo, params[0] = 0; set_param_str(params, "schema", zebra_dom_ns, tinfo->odr_record); + if (p && p->flagShowRecords) + { + xmlChar *buf_out; + int len_out; +#if 0 + FILE *outf = fopen("extract.xml", "w"); + xmlDocDumpMemory(doc, &buf_out, &len_out); + fwrite(buf_out, 1, len_out, outf); +#endif + yaz_log(YLOG_LOG, "Extract Doc: %.*s", len_out, buf_out); +#if 0 + fclose(outf); +#endif + } + /* input conversion */ perform_convert(tinfo, p, input->convert, params, &doc, 0); + if (tinfo->store) { /* store conversion */ @@ -1107,7 +1115,8 @@ static int convert_extract_doc(struct filter_info *tinfo, else xmlDocDumpMemory(store_doc ? store_doc : doc, &buf_out, &len_out); - (*p->setStoreData)(p, buf_out, len_out); + if (p->setStoreData) + (*p->setStoreData)(p, buf_out, len_out); xmlFree(buf_out); if (store_doc) @@ -1275,7 +1284,8 @@ static int extract_iso2709(struct filter_info *tinfo, { xmlDocPtr rdoc; xmlNode *root_ptr; - yaz_marc_write_xml(input->u.marc.handle, &root_ptr, 0, 0, 0); + yaz_marc_write_xml(input->u.marc.handle, &root_ptr, + "http://www.loc.gov/MARC21/slim", 0, 0); rdoc = xmlNewDoc((const xmlChar*) "1.0"); xmlDocSetRootElement(rdoc, root_ptr); return convert_extract_doc(tinfo, input, p, rdoc); @@ -1292,6 +1302,9 @@ static int filter_extract(void *clientData, struct recExtractCtrl *p) return RECCTRL_EXTRACT_ERROR_GENERIC; odr_reset(tinfo->odr_record); + + if (p->setStoreData == 0) + return extract_xml_full(tinfo, input, p); switch(input->type) { case DOM_INPUT_XMLREADER: @@ -1347,6 +1360,7 @@ static int filter_retrieve (void *clientData, struct recRetrieveCtrl *p) { p->diagnostic = YAZ_BIB1_SPECIFIED_ELEMENT_SET_NAME_NOT_VALID_FOR_SPECIFIED_; + p->addinfo = odr_strdup(p->odr, esn); return 0; } @@ -1387,7 +1401,8 @@ static int filter_retrieve (void *clientData, struct recRetrieveCtrl *p) { p->diagnostic = YAZ_BIB1_SYSTEM_ERROR_IN_PRESENTING_RECORDS; } - else if (p->input_format == VAL_NONE || p->input_format == VAL_TEXT_XML) + else if (!p->input_format + || !oid_oidcmp(p->input_format, yaz_oid_recsyn_xml)) { xmlChar *buf_out; int len_out; @@ -1397,13 +1412,13 @@ static int filter_retrieve (void *clientData, struct recRetrieveCtrl *p) else xmlDocDumpMemory(doc, &buf_out, &len_out); - p->output_format = VAL_TEXT_XML; + p->output_format = yaz_oid_recsyn_xml; p->rec_len = len_out; p->rec_buf = odr_malloc(p->odr, p->rec_len); memcpy(p->rec_buf, buf_out, p->rec_len); xmlFree(buf_out); } - else if (p->output_format == VAL_SUTRS) + else if (!oid_oidcmp(p->output_format, yaz_oid_recsyn_sutrs)) { xmlChar *buf_out; int len_out; @@ -1413,7 +1428,7 @@ static int filter_retrieve (void *clientData, struct recRetrieveCtrl *p) else xmlDocDumpMemory(doc, &buf_out, &len_out); - p->output_format = VAL_SUTRS; + p->output_format = yaz_oid_recsyn_sutrs; p->rec_len = len_out; p->rec_buf = odr_malloc(p->odr, p->rec_len); memcpy(p->rec_buf, buf_out, p->rec_len);