1 /* Copyright (C) 2006, Index Data ApS
2 * See the file LICENSE for details.
4 * $Id: nfaxml.c,v 1.3 2006-07-06 07:45:07 adam Exp $
9 * \brief Routines for reading a NFA spec from an XML file
17 #include <libxml/parser.h>
18 #include <libxml/tree.h>
19 #include <libxml/xinclude.h>
23 #include <yaz/yconfig.h>
25 #include <yaz/nfaxml.h>
26 #include <yaz/libxml2_error.h>
28 /** \brief Parse the NFA from a XML document
30 yaz_nfa *yaz_nfa_parse_xml_doc(void *xmlDocPtr)
32 xmlDocPtr doc = (xmlDocPtr) *xmlDocPtr;
39 /** \brief Log XML errors in yaz_log
41 * Disabled because xmlErrorPtr does not exist for older Libxml2's
44 static void log_xml_error(int errlevel, char *msg) {
45 xmlErrorPtr e=xmlGetLastError();
46 if (!e) /* no error happened */
50 yaz_log(errlevel,"%s %d/%d: %s:%d: '%s' ",
51 msg, e->domain, e->code, e->file, e->line, e->message);
52 if (e->str1 || e->str2 || e->str3 )
53 yaz_log(errlevel,"extra info: '%s' '%s' '%s' %d %d",
54 e->str1, e->str2, e->str3, e->int1, e->int2 );
58 /** \brief Parse the NFA from a file
60 yaz_nfa *yaz_nfa_parse_xml_file(const char *filepath) {
63 libxml2_error_to_yazlog(YLOG_FATAL, "yaz_nfa_parse_xml_file");
65 xmlDocPtr doc = xmlParseFile(filepath);
69 nSubst=xmlXIncludeProcess(doc);
73 return yaz_nfa_parse_xml_doc(doc);
78 #endif /* HAVE_XML2 */
84 * indent-tabs-mode: nil
86 * vim: shiftwidth=4 tabstop=8 expandtab