X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=index%2Fmod_grs_xml.c;h=2e9e7eaca2ac8be28bb53ca0748407183aa5572a;hb=HEAD;hp=248342b004aa50229a3f5c96adae210d21c4270d;hpb=b3679b1ecd730266f70a62347f66e5964a2fa030;p=idzebra-moved-to-github.git diff --git a/index/mod_grs_xml.c b/index/mod_grs_xml.c index 248342b..2e9e7ea 100644 --- a/index/mod_grs_xml.c +++ b/index/mod_grs_xml.c @@ -1,5 +1,5 @@ /* This file is part of the Zebra server. - Copyright (C) 1995-2008 Index Data + Copyright (C) Index Data 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 @@ -17,6 +17,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#if HAVE_CONFIG_H +#include +#endif #if HAVE_EXPAT_H #include @@ -46,6 +49,14 @@ struct user_info { int loglevel; }; +static void report_xml_error(XML_Parser parser) +{ + zint line = XML_GetCurrentLineNumber(parser); + zint col = XML_GetCurrentColumnNumber(parser); + yaz_log (YLOG_WARN, ZINT_FORMAT ":" ZINT_FORMAT ":XML error: %s", + line, col, XML_ErrorString(XML_GetErrorCode(parser))); +} + static void cb_start (void *user, const char *el, const char **attr) { struct user_info *ui = (struct user_info*) user; @@ -91,7 +102,7 @@ static void cb_decl (void *user, const char *version, const char *encoding, attr_list[5] = standalone ? "yes" : "no"; attr_list[6] = 0; - + data1_mk_preprocess (ui->dh, ui->nmem, "xml", attr_list, ui->d1_stack[ui->level-1]); #if 0 @@ -100,7 +111,7 @@ static void cb_decl (void *user, const char *version, const char *encoding, encoding ? encoding : "null"); #endif } - + static void cb_processing (void *user, const char *target, const char *data) { @@ -109,7 +120,7 @@ static void cb_processing (void *user, const char *target, data1_mk_preprocess (ui->dh, ui->nmem, target, 0, ui->d1_stack[ui->level-1]); data1_mk_text_nf (ui->dh, ui->nmem, data, strlen(data), res); - + yaz_log (ui->loglevel, "decl processing target=%s data=%s", target ? target : "null", data ? data : "null"); @@ -150,7 +161,7 @@ static void cb_entity_decl (void *userData, const char *entityName, " publicId=%s notationName=%s", entityName, is_parameter_entity, value_length, value, base, systemId, publicId, notationName); - + } static int cb_external_entity(XML_Parser pparser, @@ -199,11 +210,7 @@ static int cb_external_entity(XML_Parser pparser, if (!XML_ParseBuffer (parser, r, done)) { done = 1; - yaz_log (YLOG_WARN, "%s:%d:%d:XML error: %s", - systemId, - XML_GetCurrentLineNumber(parser), - XML_GetCurrentColumnNumber(parser), - XML_ErrorString(XML_GetErrorCode(parser))); + report_xml_error(parser); } } fclose (inf); @@ -254,7 +261,7 @@ static int cb_encoding_handler (void *userData, const char *name, iconv_t t = iconv_open ("UNICODE", name); if (t == (iconv_t) (-1)) return 0; - + info->data = 0; /* signal that multibyte is not in use */ yaz_log (ui->loglevel, "Encoding handler of %s", name); for (i = 0; i<256; i++) @@ -283,7 +290,7 @@ static int cb_encoding_handler (void *userData, const char *name, int len = 2; int j = 0; info->map[i] = -1; - + while (len <= 4) { char sbuf[80]; @@ -406,9 +413,9 @@ data1_node *zebra_read_xml(data1_handle dh, uinfo.nmem = m; uinfo.d1_stack[0] = data1_mk_node2 (dh, m, DATA1N_root, 0); uinfo.d1_stack[1] = 0; /* indicate no children (see end of routine) */ - + parser = XML_ParserCreate (0 /* encoding */); - + XML_SetElementHandler (parser, cb_start, cb_end); XML_SetCharacterDataHandler (parser, cb_chardata); XML_SetXmlDeclHandler (parser, cb_decl); @@ -446,10 +453,7 @@ data1_node *zebra_read_xml(data1_handle dh, if (no_read && !XML_ParseBuffer (parser, r, done)) { done = 1; - yaz_log (YLOG_WARN, "%d:%d:XML error: %s", - XML_GetCurrentLineNumber(parser), - XML_GetCurrentColumnNumber(parser), - XML_ErrorString(XML_GetErrorCode(parser))); + report_xml_error(parser); } } XML_ParserFree (parser); @@ -471,7 +475,7 @@ data1_node *zebra_read_xml(data1_handle dh, attr_list[3] = "UTF-8"; /* encoding */ attr_list[4] = 0; - + data1_insert_preprocess (uinfo.dh, uinfo.nmem, "xml", attr_list, uinfo.d1_stack[0]); } @@ -524,7 +528,7 @@ static struct recType filter_type = { }; RecType -#ifdef IDZEBRA_STATIC_GRS_XML +#if IDZEBRA_STATIC_GRS_XML idzebra_filter_grs_xml #else idzebra_filter @@ -534,12 +538,13 @@ idzebra_filter &filter_type, 0, }; - + #endif /* * Local variables: * c-basic-offset: 4 + * c-file-style: "Stroustrup" * indent-tabs-mode: nil * End: * vim: shiftwidth=4 tabstop=8 expandtab