Added yaz_log_trunc() to truncate the log file
[yaz-moved-to-github.git] / include / yaz / nfaxml.h
1 /*  Copyright (C) 2006, Index Data ApS
2  *  See the file LICENSE for details.
3  *  $Id: nfaxml.h,v 1.4 2006-07-06 13:10:29 heikki Exp $
4  */
5
6 /**
7  * \file nfaxml.h
8  * \brief Routines for reading NFA specs from an XML file
9  *
10  * The xml file is something like this (using round brakcets 
11  * on tags, not to confuse our documentation tools)
12  *   (?xml ...)
13  *   (charmap)
14  *      (rule)
15  *         (fromstring) FOO (/fromstring)
16  *         (tostring)   BAR (/tostring)
17  *      (/rule)
18  *      (rule)
19  *         (fromrange) a-z (/fromrange)
20  *         (torange)   A-Z (/torange)
21  *      (/rule)
22  *      ...
23  *
24  *  The rules consist of two parts, 'from' and 'to'.
25  *  From rules can be
26  *     fromstring (which can be a single character)
27  *     fromrange  (like a-z)
28  *     (later, perhaps a fromregexp)
29  *  To rules can be
30  *     tostring (which can be a single character)
31  *     torange  (only with a fromrange)
32  *     (later, perhaps backrefs from regexps)
33  */
34
35 #ifndef YAZ_NFA_XML_H
36 #define YAZ_NFA_XML_H
37
38 #if YAZ_HAVE_XML2
39
40 #include <libxml/parser.h>
41
42 #include <yaz/yconfig.h>
43 #include <yaz/log.h>
44 #include <yaz/nfa.h>
45
46 YAZ_BEGIN_CDECL
47
48 /** \brief Parse the NFA from a XML document 
49  * 
50  * \param doc the xml tree to parse
51  * \param error_info will be filled in case of errors
52  * 
53  * \returns either the NFA, or null in case of errors 
54  *
55  * It is up to the caller to destroy the nfa when done.
56  *
57  * Does not expand XIncludes.
58  *
59  * In case of errors, returns a null pointer.  You can then
60  * call xmlGetLastError() to get the details of the error,
61  * if you have a recent enough libxml2. Those are already 
62  * logged in yazlog.
63  *
64  */
65 yaz_nfa *yaz_nfa_parse_xml_doc(xmlDocPtr doc);
66
67
68 /** \brief Parse the NFA from a file 
69  *
70  * \param filepath path to the xml file to parse
71  * \param error_info will be filled in case of errors
72  * 
73  * \returns either the NFA, or null in case of errors 
74  *
75  * It is up to the caller to destroy the nfa when done.
76  *
77  * This routine also expands XIncludes.
78  * 
79  * In case of errors, returns a null pointer.  You can then
80  * call xmlGetLastError() to get the details of the error,
81  * if you have a recent enough libxml2. Those are already 
82  * logged in yazlog.
83  *
84  */
85 yaz_nfa *yaz_nfa_parse_xml_file(const char *filepath);
86
87
88 /** \brief Parse the NFA from a memory buffer
89  *
90  * \param filepath path to the xml file to parse
91  * \param error_info will be filled in case of errors
92  * 
93  * \returns either the NFA, or null in case of errors 
94  *
95  * It is up to the caller to destroy the nfa when done.
96  *
97  * Does not expand XIncludes.
98  *
99  * In case of errors, returns a null pointer.  You can then
100  * call xmlGetLastError() to get the details of the error,
101  * if you have a recent enough libxml2. Those are already 
102  * logged in yazlog.
103  *
104  */
105 yaz_nfa *yaz_nfa_parse_xml_memory(const char *xmlbuff);
106
107
108 YAZ_END_CDECL
109    
110 #endif /* YAZ_HAVE_XML2 */
111 #endif /* YAZ_NFA_XML_H */
112
113 /*
114  * Local variables:
115  * c-basic-offset: 4
116  * indent-tabs-mode: nil
117  * End:
118  * vim: shiftwidth=4 tabstop=8 expandtab
119  */
120