|
1 /* |
|
2 * Summary: implementation of the Relax-NG validation |
|
3 * Description: implementation of the Relax-NG validation |
|
4 * |
|
5 * Copy: See Copyright for the status of this software. |
|
6 * |
|
7 * Author: Daniel Veillard |
|
8 */ |
|
9 |
|
10 #ifndef __XML_RELAX_NG__ |
|
11 #define __XML_RELAX_NG__ |
|
12 |
|
13 #include <libxml/xmlversion.h> |
|
14 #include <libxml/hash.h> |
|
15 #include <libxml/xmlstring.h> |
|
16 |
|
17 #ifdef LIBXML_SCHEMAS_ENABLED |
|
18 |
|
19 #ifdef __cplusplus |
|
20 extern "C" { |
|
21 #endif |
|
22 |
|
23 typedef struct _xmlRelaxNG xmlRelaxNG; |
|
24 typedef xmlRelaxNG *xmlRelaxNGPtr; |
|
25 |
|
26 |
|
27 /** |
|
28 * A schemas validation context |
|
29 */ |
|
30 typedef void (XMLCDECL *xmlRelaxNGValidityErrorFunc) (void *ctx, const char *msg, ...); |
|
31 typedef void (XMLCDECL *xmlRelaxNGValidityWarningFunc) (void *ctx, const char *msg, ...); |
|
32 |
|
33 typedef struct _xmlRelaxNGParserCtxt xmlRelaxNGParserCtxt; |
|
34 typedef xmlRelaxNGParserCtxt *xmlRelaxNGParserCtxtPtr; |
|
35 |
|
36 typedef struct _xmlRelaxNGValidCtxt xmlRelaxNGValidCtxt; |
|
37 typedef xmlRelaxNGValidCtxt *xmlRelaxNGValidCtxtPtr; |
|
38 |
|
39 /* |
|
40 * xmlRelaxNGValidErr: |
|
41 * |
|
42 * List of possible Relax NG validation errors |
|
43 */ |
|
44 typedef enum { |
|
45 XML_RELAXNG_OK = 0, |
|
46 XML_RELAXNG_ERR_MEMORY, |
|
47 XML_RELAXNG_ERR_TYPE, |
|
48 XML_RELAXNG_ERR_TYPEVAL, |
|
49 XML_RELAXNG_ERR_DUPID, |
|
50 XML_RELAXNG_ERR_TYPECMP, |
|
51 XML_RELAXNG_ERR_NOSTATE, |
|
52 XML_RELAXNG_ERR_NODEFINE, |
|
53 XML_RELAXNG_ERR_LISTEXTRA, |
|
54 XML_RELAXNG_ERR_LISTEMPTY, |
|
55 XML_RELAXNG_ERR_INTERNODATA, |
|
56 XML_RELAXNG_ERR_INTERSEQ, |
|
57 XML_RELAXNG_ERR_INTEREXTRA, |
|
58 XML_RELAXNG_ERR_ELEMNAME, |
|
59 XML_RELAXNG_ERR_ATTRNAME, |
|
60 XML_RELAXNG_ERR_ELEMNONS, |
|
61 XML_RELAXNG_ERR_ATTRNONS, |
|
62 XML_RELAXNG_ERR_ELEMWRONGNS, |
|
63 XML_RELAXNG_ERR_ATTRWRONGNS, |
|
64 XML_RELAXNG_ERR_ELEMEXTRANS, |
|
65 XML_RELAXNG_ERR_ATTREXTRANS, |
|
66 XML_RELAXNG_ERR_ELEMNOTEMPTY, |
|
67 XML_RELAXNG_ERR_NOELEM, |
|
68 XML_RELAXNG_ERR_NOTELEM, |
|
69 XML_RELAXNG_ERR_ATTRVALID, |
|
70 XML_RELAXNG_ERR_CONTENTVALID, |
|
71 XML_RELAXNG_ERR_EXTRACONTENT, |
|
72 XML_RELAXNG_ERR_INVALIDATTR, |
|
73 XML_RELAXNG_ERR_DATAELEM, |
|
74 XML_RELAXNG_ERR_VALELEM, |
|
75 XML_RELAXNG_ERR_LISTELEM, |
|
76 XML_RELAXNG_ERR_DATATYPE, |
|
77 XML_RELAXNG_ERR_VALUE, |
|
78 XML_RELAXNG_ERR_LIST, |
|
79 XML_RELAXNG_ERR_NOGRAMMAR, |
|
80 XML_RELAXNG_ERR_EXTRADATA, |
|
81 XML_RELAXNG_ERR_LACKDATA, |
|
82 XML_RELAXNG_ERR_INTERNAL, |
|
83 XML_RELAXNG_ERR_ELEMWRONG, |
|
84 XML_RELAXNG_ERR_TEXTWRONG |
|
85 } xmlRelaxNGValidErr; |
|
86 |
|
87 /* |
|
88 * xmlRelaxNGParserFlags: |
|
89 * |
|
90 * List of possible Relax NG Parser flags |
|
91 */ |
|
92 typedef enum { |
|
93 XML_RELAXNGP_NONE = 0, |
|
94 XML_RELAXNGP_FREE_DOC = 1, |
|
95 XML_RELAXNGP_CRNG = 2 |
|
96 } xmlRelaxNGParserFlag; |
|
97 |
|
98 XMLPUBFUN int XMLCALL |
|
99 xmlRelaxNGInitTypes (void); |
|
100 XMLPUBFUN void XMLCALL |
|
101 xmlRelaxNGCleanupTypes (void); |
|
102 |
|
103 /* |
|
104 * Interfaces for parsing. |
|
105 */ |
|
106 XMLPUBFUN xmlRelaxNGParserCtxtPtr XMLCALL |
|
107 xmlRelaxNGNewParserCtxt (const char *URL); |
|
108 XMLPUBFUN xmlRelaxNGParserCtxtPtr XMLCALL |
|
109 xmlRelaxNGNewMemParserCtxt (const char *buffer, |
|
110 int size); |
|
111 XMLPUBFUN xmlRelaxNGParserCtxtPtr XMLCALL |
|
112 xmlRelaxNGNewDocParserCtxt (xmlDocPtr doc); |
|
113 |
|
114 XMLPUBFUN int XMLCALL |
|
115 xmlRelaxParserSetFlag (xmlRelaxNGParserCtxtPtr ctxt, |
|
116 int flag); |
|
117 |
|
118 XMLPUBFUN void XMLCALL |
|
119 xmlRelaxNGFreeParserCtxt (xmlRelaxNGParserCtxtPtr ctxt); |
|
120 XMLPUBFUN void XMLCALL |
|
121 xmlRelaxNGSetParserErrors(xmlRelaxNGParserCtxtPtr ctxt, |
|
122 xmlRelaxNGValidityErrorFunc err, |
|
123 xmlRelaxNGValidityWarningFunc warn, |
|
124 void *ctx); |
|
125 XMLPUBFUN int XMLCALL |
|
126 xmlRelaxNGGetParserErrors(xmlRelaxNGParserCtxtPtr ctxt, |
|
127 xmlRelaxNGValidityErrorFunc *err, |
|
128 xmlRelaxNGValidityWarningFunc *warn, |
|
129 void **ctx); |
|
130 XMLPUBFUN xmlRelaxNGPtr XMLCALL |
|
131 xmlRelaxNGParse (xmlRelaxNGParserCtxtPtr ctxt); |
|
132 XMLPUBFUN void XMLCALL |
|
133 xmlRelaxNGFree (xmlRelaxNGPtr schema); |
|
134 #ifdef LIBXML_OUTPUT_ENABLED |
|
135 XMLPUBFUN void XMLCALL |
|
136 xmlRelaxNGDump (FILE *output, |
|
137 xmlRelaxNGPtr schema); |
|
138 XMLPUBFUN void XMLCALL |
|
139 xmlRelaxNGDumpTree (FILE * output, |
|
140 xmlRelaxNGPtr schema); |
|
141 #endif /* LIBXML_OUTPUT_ENABLED */ |
|
142 /* |
|
143 * Interfaces for validating |
|
144 */ |
|
145 XMLPUBFUN void XMLCALL |
|
146 xmlRelaxNGSetValidErrors(xmlRelaxNGValidCtxtPtr ctxt, |
|
147 xmlRelaxNGValidityErrorFunc err, |
|
148 xmlRelaxNGValidityWarningFunc warn, |
|
149 void *ctx); |
|
150 XMLPUBFUN int XMLCALL |
|
151 xmlRelaxNGGetValidErrors(xmlRelaxNGValidCtxtPtr ctxt, |
|
152 xmlRelaxNGValidityErrorFunc *err, |
|
153 xmlRelaxNGValidityWarningFunc *warn, |
|
154 void **ctx); |
|
155 XMLPUBFUN void XMLCALL |
|
156 xmlRelaxNGSetValidStructuredErrors(xmlRelaxNGValidCtxtPtr ctxt, |
|
157 xmlStructuredErrorFunc serror, void *ctx); |
|
158 XMLPUBFUN xmlRelaxNGValidCtxtPtr XMLCALL |
|
159 xmlRelaxNGNewValidCtxt (xmlRelaxNGPtr schema); |
|
160 XMLPUBFUN void XMLCALL |
|
161 xmlRelaxNGFreeValidCtxt (xmlRelaxNGValidCtxtPtr ctxt); |
|
162 XMLPUBFUN int XMLCALL |
|
163 xmlRelaxNGValidateDoc (xmlRelaxNGValidCtxtPtr ctxt, |
|
164 xmlDocPtr doc); |
|
165 /* |
|
166 * Interfaces for progressive validation when possible |
|
167 */ |
|
168 XMLPUBFUN int XMLCALL |
|
169 xmlRelaxNGValidatePushElement (xmlRelaxNGValidCtxtPtr ctxt, |
|
170 xmlDocPtr doc, |
|
171 xmlNodePtr elem); |
|
172 XMLPUBFUN int XMLCALL |
|
173 xmlRelaxNGValidatePushCData (xmlRelaxNGValidCtxtPtr ctxt, |
|
174 const xmlChar *data, |
|
175 int len); |
|
176 XMLPUBFUN int XMLCALL |
|
177 xmlRelaxNGValidatePopElement (xmlRelaxNGValidCtxtPtr ctxt, |
|
178 xmlDocPtr doc, |
|
179 xmlNodePtr elem); |
|
180 XMLPUBFUN int XMLCALL |
|
181 xmlRelaxNGValidateFullElement (xmlRelaxNGValidCtxtPtr ctxt, |
|
182 xmlDocPtr doc, |
|
183 xmlNodePtr elem); |
|
184 |
|
185 #ifdef __cplusplus |
|
186 } |
|
187 #endif |
|
188 |
|
189 #endif /* LIBXML_SCHEMAS_ENABLED */ |
|
190 |
|
191 #endif /* __XML_RELAX_NG__ */ |