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