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 void XMLCALL
|
---|
131 | xmlRelaxNGSetParserStructuredErrors(
|
---|
132 | xmlRelaxNGParserCtxtPtr ctxt,
|
---|
133 | xmlStructuredErrorFunc serror,
|
---|
134 | void *ctx);
|
---|
135 | XMLPUBFUN xmlRelaxNGPtr XMLCALL
|
---|
136 | xmlRelaxNGParse (xmlRelaxNGParserCtxtPtr ctxt);
|
---|
137 | XMLPUBFUN void XMLCALL
|
---|
138 | xmlRelaxNGFree (xmlRelaxNGPtr schema);
|
---|
139 | #ifdef LIBXML_OUTPUT_ENABLED
|
---|
140 | XMLPUBFUN void XMLCALL
|
---|
141 | xmlRelaxNGDump (FILE *output,
|
---|
142 | xmlRelaxNGPtr schema);
|
---|
143 | XMLPUBFUN void XMLCALL
|
---|
144 | xmlRelaxNGDumpTree (FILE * output,
|
---|
145 | xmlRelaxNGPtr schema);
|
---|
146 | #endif /* LIBXML_OUTPUT_ENABLED */
|
---|
147 | /*
|
---|
148 | * Interfaces for validating
|
---|
149 | */
|
---|
150 | XMLPUBFUN void XMLCALL
|
---|
151 | xmlRelaxNGSetValidErrors(xmlRelaxNGValidCtxtPtr ctxt,
|
---|
152 | xmlRelaxNGValidityErrorFunc err,
|
---|
153 | xmlRelaxNGValidityWarningFunc warn,
|
---|
154 | void *ctx);
|
---|
155 | XMLPUBFUN int XMLCALL
|
---|
156 | xmlRelaxNGGetValidErrors(xmlRelaxNGValidCtxtPtr ctxt,
|
---|
157 | xmlRelaxNGValidityErrorFunc *err,
|
---|
158 | xmlRelaxNGValidityWarningFunc *warn,
|
---|
159 | void **ctx);
|
---|
160 | XMLPUBFUN void XMLCALL
|
---|
161 | xmlRelaxNGSetValidStructuredErrors(xmlRelaxNGValidCtxtPtr ctxt,
|
---|
162 | xmlStructuredErrorFunc serror, void *ctx);
|
---|
163 | XMLPUBFUN xmlRelaxNGValidCtxtPtr XMLCALL
|
---|
164 | xmlRelaxNGNewValidCtxt (xmlRelaxNGPtr schema);
|
---|
165 | XMLPUBFUN void XMLCALL
|
---|
166 | xmlRelaxNGFreeValidCtxt (xmlRelaxNGValidCtxtPtr ctxt);
|
---|
167 | XMLPUBFUN int XMLCALL
|
---|
168 | xmlRelaxNGValidateDoc (xmlRelaxNGValidCtxtPtr ctxt,
|
---|
169 | xmlDocPtr doc);
|
---|
170 | /*
|
---|
171 | * Interfaces for progressive validation when possible
|
---|
172 | */
|
---|
173 | XMLPUBFUN int XMLCALL
|
---|
174 | xmlRelaxNGValidatePushElement (xmlRelaxNGValidCtxtPtr ctxt,
|
---|
175 | xmlDocPtr doc,
|
---|
176 | xmlNodePtr elem);
|
---|
177 | XMLPUBFUN int XMLCALL
|
---|
178 | xmlRelaxNGValidatePushCData (xmlRelaxNGValidCtxtPtr ctxt,
|
---|
179 | const xmlChar *data,
|
---|
180 | int len);
|
---|
181 | XMLPUBFUN int XMLCALL
|
---|
182 | xmlRelaxNGValidatePopElement (xmlRelaxNGValidCtxtPtr ctxt,
|
---|
183 | xmlDocPtr doc,
|
---|
184 | xmlNodePtr elem);
|
---|
185 | XMLPUBFUN int XMLCALL
|
---|
186 | xmlRelaxNGValidateFullElement (xmlRelaxNGValidCtxtPtr ctxt,
|
---|
187 | xmlDocPtr doc,
|
---|
188 | xmlNodePtr elem);
|
---|
189 |
|
---|
190 | #ifdef __cplusplus
|
---|
191 | }
|
---|
192 | #endif
|
---|
193 |
|
---|
194 | #endif /* LIBXML_SCHEMAS_ENABLED */
|
---|
195 |
|
---|
196 | #endif /* __XML_RELAX_NG__ */
|
---|