Change wording ot YAZ license the 'Revised BSD License'. YAZ has used a
[yaz-moved-to-github.git] / include / yaz / nfaxml.h
1 /*
2  * Copyright (c) 1995-2006, Index Data
3  * All rights reserved.
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are met:
6  *
7  *     * Redistributions of source code must retain the above copyright
8  *       notice, this list of conditions and the following disclaimer.
9  *     * Redistributions in binary form must reproduce the above copyright
10  *       notice, this list of conditions and the following disclaimer in the
11  *       documentation and/or other materials provided with the distribution.
12  *     * Neither the name of Index Data nor the names of its contributors
13  *       may be used to endorse or promote products derived from this
14  *       software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY
17  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19  * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY
20  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27 /* $Id: nfaxml.h,v 1.6 2006-10-09 21:02:41 adam Exp $ */
28
29 /**
30  * \file nfaxml.h
31  * \brief Routines for reading NFA specs from an XML file
32  *
33  * The xml file is something like this (using round brakcets 
34  * on tags, not to confuse our documentation tools)
35  *   (?xml ...)
36  *   (ruleset)
37  *      (rule)
38  *         (fromstring) FOO (/fromstring)
39  *         (tostring)   BAR (/tostring)
40  *      (/rule)
41  *      (rule)
42  *         (fromrange) a-z (/fromrange)
43  *         (torange)   A-Z (/torange)
44  *      (/rule)
45  *      ...
46  *
47  *  The rules consist of two parts, 'from' and 'to'.
48  *  From rules can be
49  *     fromstring (which can be a single character)
50  *     fromrange  (like a-z)
51  *     (later, perhaps a fromregexp)
52  *  To rules can be
53  *     tostring (which can be a single character)
54  *     torange  (only with a fromrange)
55  *     (later, perhaps backrefs from regexps)
56  */
57
58 #ifndef YAZ_NFA_XML_H
59 #define YAZ_NFA_XML_H
60
61 #if YAZ_HAVE_XML2
62
63 #include <libxml/parser.h>
64
65 #include <yaz/yconfig.h>
66 #include <yaz/log.h>
67 #include <yaz/nfa.h>
68
69 YAZ_BEGIN_CDECL
70
71 /** \brief Parse the NFA from a XML document 
72  * 
73  * \param doc the xml tree to parse
74  * \param filename used for info in error messages
75  * 
76  * \returns either the NFA, or null in case of errors 
77  *
78  * It is up to the caller to destroy the nfa when done.
79  *
80  * Does not expand XIncludes.
81  *
82  * In case of errors, returns a null pointer.  You can then
83  * call xmlGetLastError() to get the details of the error,
84  * if you have a recent enough libxml2. Those are already 
85  * logged in yazlog.
86  *
87  */
88 yaz_nfa *yaz_nfa_parse_xml_doc(xmlDocPtr doc, const char *filename);
89
90
91 /** \brief Parse the NFA from a file 
92  *
93  * \param filepath path to the xml file to parse
94  * \param error_info will be filled in case of errors
95  * 
96  * \returns either the NFA, or null in case of errors 
97  *
98  * It is up to the caller to destroy the nfa when done.
99  *
100  * This routine also expands XIncludes.
101  * 
102  * In case of errors, returns a null pointer.  You can then
103  * call xmlGetLastError() to get the details of the error,
104  * if you have a recent enough libxml2. Those are already 
105  * logged in yazlog.
106  *
107  */
108 yaz_nfa *yaz_nfa_parse_xml_file(const char *filepath);
109
110
111 /** \brief Parse the NFA from a memory buffer
112  *
113  * \param filepath path to the xml file to parse
114  * \param error_info will be filled in case of errors
115  * 
116  * \returns either the NFA, or null in case of errors 
117  *
118  * It is up to the caller to destroy the nfa when done.
119  *
120  * Does not expand XIncludes.
121  *
122  * In case of errors, returns a null pointer.  You can then
123  * call xmlGetLastError() to get the details of the error,
124  * if you have a recent enough libxml2. Those are already 
125  * logged in yazlog.
126  *
127  */
128 yaz_nfa *yaz_nfa_parse_xml_memory(const char *xmlbuff, const char *filename);
129
130
131 YAZ_END_CDECL
132    
133 #endif /* YAZ_HAVE_XML2 */
134 #endif /* YAZ_NFA_XML_H */
135
136 /*
137  * Local variables:
138  * c-basic-offset: 4
139  * indent-tabs-mode: nil
140  * End:
141  * vim: shiftwidth=4 tabstop=8 expandtab
142  */
143