Disabled log_xml_error because it doesn't work on older Libxml2 and
[yaz-moved-to-github.git] / src / nfaxml.c
1 /*  Copyright (C) 2006, Index Data ApS
2  *  See the file LICENSE for details.
3  * 
4  *  $Id: nfaxml.c,v 1.2 2006-07-06 06:09:12 adam Exp $ 
5  */
6
7 /**
8  * \file nfaxml.c
9  * \brief Routines for reading a NFA spec from an XML file
10  *
11  */
12
13 #if HAVE_XML2
14
15 #include <string.h>
16
17 #include <libxml/parser.h>
18 #include <libxml/tree.h>
19 #include <libxml/xinclude.h>
20
21 #include <yaz/nfa.h>
22 #include <yaz/nmem.h> 
23 #include <yaz/yconfig.h>
24 #include <yaz/nfa.h>
25 #include <yaz/nfaxml.h>
26
27
28 /** \brief Parse the NFA from a XML document 
29  */
30 yaz_nfa *yaz_nfa_parse_xml_doc(xmlDocPtr doc){
31     if (!doc)
32         return 0;
33
34     return 0;
35 }
36
37 /** \brief Log XML errors in yaz_log
38  *
39  * Disabled because xmlErrorPtr does not exist for older Libxml2's
40  */
41 #if 0
42 static void log_xml_error(int errlevel, char *msg) {
43     xmlErrorPtr e=xmlGetLastError();
44     if (!e)  /* no error happened */
45         return;
46     if (!errlevel)
47         errlevel=YLOG_FATAL;
48     yaz_log(errlevel,"%s %d/%d: %s:%d: '%s' ",
49             msg, e->domain, e->code, e->file, e->line, e->message);
50     if (e->str1 || e->str2 || e->str3 )
51         yaz_log(errlevel,"extra info: '%s' '%s' '%s' %d %d",
52             e->str1, e->str2, e->str3, e->int1, e->int2 );
53 }
54 #endif
55
56 /** \brief Parse the NFA from a file 
57  */
58 yaz_nfa *yaz_nfa_parse_xml_file(const char *filepath) {
59     int nSubst;
60
61     libxml2_error_to_yazlog(YLOG_FATAL, "yaz_nfa_parse_xml_file");
62
63     xmlDocPtr doc = xmlParseFile(filepath);
64     if (!doc) {
65         return 0;
66     }
67     nSubst=xmlXIncludeProcess(doc);
68     if (nSubst==-1) {
69         return 0;
70     }
71     return yaz_nfa_parse_xml_doc(doc);
72 }
73
74
75
76 #endif /* HAVE_XML2 */
77
78
79 /*
80  * Local variables:
81  * c-basic-offset: 4
82  * indent-tabs-mode: nil
83  * End:
84  * vim: shiftwidth=4 tabstop=8 expandtab
85  */