Daniel Veillard | 6eadf63 | 2003-01-23 18:29:16 +0000 | [diff] [blame] | 1 | /* |
Daniel Veillard | be58697 | 2003-11-18 20:56:51 +0000 | [diff] [blame] | 2 | * Summary: implementation of the Relax-NG validation |
| 3 | * Description: implementation of the Relax-NG validation |
Daniel Veillard | 6eadf63 | 2003-01-23 18:29:16 +0000 | [diff] [blame] | 4 | * |
Daniel Veillard | be58697 | 2003-11-18 20:56:51 +0000 | [diff] [blame] | 5 | * Copy: See Copyright for the status of this software. |
Daniel Veillard | 6eadf63 | 2003-01-23 18:29:16 +0000 | [diff] [blame] | 6 | * |
Daniel Veillard | be58697 | 2003-11-18 20:56:51 +0000 | [diff] [blame] | 7 | * Author: Daniel Veillard |
Daniel Veillard | 6eadf63 | 2003-01-23 18:29:16 +0000 | [diff] [blame] | 8 | */ |
| 9 | |
| 10 | #ifndef __XML_RELAX_NG__ |
| 11 | #define __XML_RELAX_NG__ |
| 12 | |
Igor Zlatkovic | 76874e4 | 2003-08-25 09:05:12 +0000 | [diff] [blame] | 13 | #include <libxml/xmlversion.h> |
Daniel Veillard | 6eadf63 | 2003-01-23 18:29:16 +0000 | [diff] [blame] | 14 | #include <libxml/hash.h> |
William M. Brack | a2e844a | 2004-01-06 11:52:13 +0000 | [diff] [blame] | 15 | #include <libxml/xmlstring.h> |
Daniel Veillard | 6eadf63 | 2003-01-23 18:29:16 +0000 | [diff] [blame] | 16 | |
Daniel Veillard | a235132 | 2004-06-27 12:08:10 +0000 | [diff] [blame] | 17 | #ifdef LIBXML_SCHEMAS_ENABLED |
| 18 | |
Daniel Veillard | 94394cd | 2003-10-29 17:07:51 +0000 | [diff] [blame] | 19 | #ifdef __cplusplus |
| 20 | extern "C" { |
| 21 | #endif |
| 22 | |
Daniel Veillard | 6eadf63 | 2003-01-23 18:29:16 +0000 | [diff] [blame] | 23 | typedef struct _xmlRelaxNG xmlRelaxNG; |
| 24 | typedef xmlRelaxNG *xmlRelaxNGPtr; |
| 25 | |
| 26 | |
| 27 | /** |
Daniel Veillard | dee2348 | 2008-04-11 12:58:43 +0000 | [diff] [blame] | 28 | * xmlRelaxNGValidityErrorFunc: |
| 29 | * @ctx: the validation context |
| 30 | * @msg: the message |
| 31 | * @...: extra arguments |
| 32 | * |
| 33 | * Signature of an error callback from a Relax-NG validation |
Daniel Veillard | 6eadf63 | 2003-01-23 18:29:16 +0000 | [diff] [blame] | 34 | */ |
Patrick Monnerat | 44313c0 | 2013-12-12 14:59:18 +0800 | [diff] [blame] | 35 | typedef void (XMLCDECL *xmlRelaxNGValidityErrorFunc) (void *ctx, |
| 36 | const char *msg, |
| 37 | ...) LIBXML_ATTR_FORMAT(2,3); |
Daniel Veillard | dee2348 | 2008-04-11 12:58:43 +0000 | [diff] [blame] | 38 | |
| 39 | /** |
| 40 | * xmlRelaxNGValidityWarningFunc: |
| 41 | * @ctx: the validation context |
| 42 | * @msg: the message |
| 43 | * @...: extra arguments |
| 44 | * |
| 45 | * Signature of a warning callback from a Relax-NG validation |
| 46 | */ |
Patrick Monnerat | 44313c0 | 2013-12-12 14:59:18 +0800 | [diff] [blame] | 47 | typedef void (XMLCDECL *xmlRelaxNGValidityWarningFunc) (void *ctx, |
| 48 | const char *msg, |
| 49 | ...) LIBXML_ATTR_FORMAT(2,3); |
Daniel Veillard | 6eadf63 | 2003-01-23 18:29:16 +0000 | [diff] [blame] | 50 | |
Daniel Veillard | dee2348 | 2008-04-11 12:58:43 +0000 | [diff] [blame] | 51 | /** |
| 52 | * A schemas validation context |
| 53 | */ |
Daniel Veillard | 6eadf63 | 2003-01-23 18:29:16 +0000 | [diff] [blame] | 54 | typedef struct _xmlRelaxNGParserCtxt xmlRelaxNGParserCtxt; |
| 55 | typedef xmlRelaxNGParserCtxt *xmlRelaxNGParserCtxtPtr; |
| 56 | |
| 57 | typedef struct _xmlRelaxNGValidCtxt xmlRelaxNGValidCtxt; |
| 58 | typedef xmlRelaxNGValidCtxt *xmlRelaxNGValidCtxtPtr; |
| 59 | |
| 60 | /* |
Daniel Veillard | 42f12e9 | 2003-03-07 18:32:59 +0000 | [diff] [blame] | 61 | * xmlRelaxNGValidErr: |
| 62 | * |
| 63 | * List of possible Relax NG validation errors |
| 64 | */ |
| 65 | typedef enum { |
| 66 | XML_RELAXNG_OK = 0, |
| 67 | XML_RELAXNG_ERR_MEMORY, |
| 68 | XML_RELAXNG_ERR_TYPE, |
| 69 | XML_RELAXNG_ERR_TYPEVAL, |
Daniel Veillard | c3da18a | 2003-03-18 00:31:04 +0000 | [diff] [blame] | 70 | XML_RELAXNG_ERR_DUPID, |
Daniel Veillard | 42f12e9 | 2003-03-07 18:32:59 +0000 | [diff] [blame] | 71 | XML_RELAXNG_ERR_TYPECMP, |
| 72 | XML_RELAXNG_ERR_NOSTATE, |
| 73 | XML_RELAXNG_ERR_NODEFINE, |
| 74 | XML_RELAXNG_ERR_LISTEXTRA, |
Daniel Veillard | 1564e6e | 2003-03-15 21:30:25 +0000 | [diff] [blame] | 75 | XML_RELAXNG_ERR_LISTEMPTY, |
Daniel Veillard | 42f12e9 | 2003-03-07 18:32:59 +0000 | [diff] [blame] | 76 | XML_RELAXNG_ERR_INTERNODATA, |
| 77 | XML_RELAXNG_ERR_INTERSEQ, |
| 78 | XML_RELAXNG_ERR_INTEREXTRA, |
| 79 | XML_RELAXNG_ERR_ELEMNAME, |
Daniel Veillard | 1564e6e | 2003-03-15 21:30:25 +0000 | [diff] [blame] | 80 | XML_RELAXNG_ERR_ATTRNAME, |
Daniel Veillard | 42f12e9 | 2003-03-07 18:32:59 +0000 | [diff] [blame] | 81 | XML_RELAXNG_ERR_ELEMNONS, |
Daniel Veillard | 1564e6e | 2003-03-15 21:30:25 +0000 | [diff] [blame] | 82 | XML_RELAXNG_ERR_ATTRNONS, |
Daniel Veillard | 42f12e9 | 2003-03-07 18:32:59 +0000 | [diff] [blame] | 83 | XML_RELAXNG_ERR_ELEMWRONGNS, |
Daniel Veillard | 1564e6e | 2003-03-15 21:30:25 +0000 | [diff] [blame] | 84 | XML_RELAXNG_ERR_ATTRWRONGNS, |
Daniel Veillard | 42f12e9 | 2003-03-07 18:32:59 +0000 | [diff] [blame] | 85 | XML_RELAXNG_ERR_ELEMEXTRANS, |
Daniel Veillard | 1564e6e | 2003-03-15 21:30:25 +0000 | [diff] [blame] | 86 | XML_RELAXNG_ERR_ATTREXTRANS, |
Daniel Veillard | 42f12e9 | 2003-03-07 18:32:59 +0000 | [diff] [blame] | 87 | XML_RELAXNG_ERR_ELEMNOTEMPTY, |
| 88 | XML_RELAXNG_ERR_NOELEM, |
| 89 | XML_RELAXNG_ERR_NOTELEM, |
| 90 | XML_RELAXNG_ERR_ATTRVALID, |
| 91 | XML_RELAXNG_ERR_CONTENTVALID, |
| 92 | XML_RELAXNG_ERR_EXTRACONTENT, |
| 93 | XML_RELAXNG_ERR_INVALIDATTR, |
| 94 | XML_RELAXNG_ERR_DATAELEM, |
| 95 | XML_RELAXNG_ERR_VALELEM, |
| 96 | XML_RELAXNG_ERR_LISTELEM, |
| 97 | XML_RELAXNG_ERR_DATATYPE, |
| 98 | XML_RELAXNG_ERR_VALUE, |
| 99 | XML_RELAXNG_ERR_LIST, |
| 100 | XML_RELAXNG_ERR_NOGRAMMAR, |
Daniel Veillard | fd573f1 | 2003-03-16 17:52:32 +0000 | [diff] [blame] | 101 | XML_RELAXNG_ERR_EXTRADATA, |
Daniel Veillard | 952379b | 2003-03-17 15:37:12 +0000 | [diff] [blame] | 102 | XML_RELAXNG_ERR_LACKDATA, |
Daniel Veillard | c58f4ef | 2003-04-14 16:11:26 +0000 | [diff] [blame] | 103 | XML_RELAXNG_ERR_INTERNAL, |
| 104 | XML_RELAXNG_ERR_ELEMWRONG, |
| 105 | XML_RELAXNG_ERR_TEXTWRONG |
Daniel Veillard | 42f12e9 | 2003-03-07 18:32:59 +0000 | [diff] [blame] | 106 | } xmlRelaxNGValidErr; |
| 107 | |
| 108 | /* |
Daniel Veillard | 03c2f0a | 2004-01-25 19:54:59 +0000 | [diff] [blame] | 109 | * xmlRelaxNGParserFlags: |
| 110 | * |
| 111 | * List of possible Relax NG Parser flags |
| 112 | */ |
| 113 | typedef enum { |
| 114 | XML_RELAXNGP_NONE = 0, |
| 115 | XML_RELAXNGP_FREE_DOC = 1, |
| 116 | XML_RELAXNGP_CRNG = 2 |
| 117 | } xmlRelaxNGParserFlag; |
Daniel Veillard | dd6d300 | 2004-11-03 14:20:29 +0000 | [diff] [blame] | 118 | |
| 119 | XMLPUBFUN int XMLCALL |
| 120 | xmlRelaxNGInitTypes (void); |
Daniel Veillard | f63085d | 2009-01-18 20:53:59 +0000 | [diff] [blame] | 121 | XMLPUBFUN void XMLCALL |
Daniel Veillard | dd6d300 | 2004-11-03 14:20:29 +0000 | [diff] [blame] | 122 | xmlRelaxNGCleanupTypes (void); |
| 123 | |
Daniel Veillard | 03c2f0a | 2004-01-25 19:54:59 +0000 | [diff] [blame] | 124 | /* |
Daniel Veillard | 6eadf63 | 2003-01-23 18:29:16 +0000 | [diff] [blame] | 125 | * Interfaces for parsing. |
| 126 | */ |
Daniel Veillard | f63085d | 2009-01-18 20:53:59 +0000 | [diff] [blame] | 127 | XMLPUBFUN xmlRelaxNGParserCtxtPtr XMLCALL |
Igor Zlatkovic | 76874e4 | 2003-08-25 09:05:12 +0000 | [diff] [blame] | 128 | xmlRelaxNGNewParserCtxt (const char *URL); |
Daniel Veillard | f63085d | 2009-01-18 20:53:59 +0000 | [diff] [blame] | 129 | XMLPUBFUN xmlRelaxNGParserCtxtPtr XMLCALL |
Igor Zlatkovic | 93f984a | 2003-08-25 10:34:41 +0000 | [diff] [blame] | 130 | xmlRelaxNGNewMemParserCtxt (const char *buffer, |
Daniel Veillard | 6eadf63 | 2003-01-23 18:29:16 +0000 | [diff] [blame] | 131 | int size); |
Daniel Veillard | f63085d | 2009-01-18 20:53:59 +0000 | [diff] [blame] | 132 | XMLPUBFUN xmlRelaxNGParserCtxtPtr XMLCALL |
Igor Zlatkovic | 93f984a | 2003-08-25 10:34:41 +0000 | [diff] [blame] | 133 | xmlRelaxNGNewDocParserCtxt (xmlDocPtr doc); |
Daniel Veillard | 33300b4 | 2003-04-17 09:09:19 +0000 | [diff] [blame] | 134 | |
Daniel Veillard | 03c2f0a | 2004-01-25 19:54:59 +0000 | [diff] [blame] | 135 | XMLPUBFUN int XMLCALL |
| 136 | xmlRelaxParserSetFlag (xmlRelaxNGParserCtxtPtr ctxt, |
Daniel Veillard | f63085d | 2009-01-18 20:53:59 +0000 | [diff] [blame] | 137 | int flag); |
Daniel Veillard | 03c2f0a | 2004-01-25 19:54:59 +0000 | [diff] [blame] | 138 | |
Daniel Veillard | f63085d | 2009-01-18 20:53:59 +0000 | [diff] [blame] | 139 | XMLPUBFUN void XMLCALL |
Igor Zlatkovic | 93f984a | 2003-08-25 10:34:41 +0000 | [diff] [blame] | 140 | xmlRelaxNGFreeParserCtxt (xmlRelaxNGParserCtxtPtr ctxt); |
Daniel Veillard | f63085d | 2009-01-18 20:53:59 +0000 | [diff] [blame] | 141 | XMLPUBFUN void XMLCALL |
Igor Zlatkovic | 93f984a | 2003-08-25 10:34:41 +0000 | [diff] [blame] | 142 | xmlRelaxNGSetParserErrors(xmlRelaxNGParserCtxtPtr ctxt, |
Daniel Veillard | 6eadf63 | 2003-01-23 18:29:16 +0000 | [diff] [blame] | 143 | xmlRelaxNGValidityErrorFunc err, |
| 144 | xmlRelaxNGValidityWarningFunc warn, |
| 145 | void *ctx); |
Igor Zlatkovic | 93f984a | 2003-08-25 10:34:41 +0000 | [diff] [blame] | 146 | XMLPUBFUN int XMLCALL |
| 147 | xmlRelaxNGGetParserErrors(xmlRelaxNGParserCtxtPtr ctxt, |
Daniel Veillard | 409a814 | 2003-07-18 15:16:57 +0000 | [diff] [blame] | 148 | xmlRelaxNGValidityErrorFunc *err, |
| 149 | xmlRelaxNGValidityWarningFunc *warn, |
| 150 | void **ctx); |
Kasimier T. Buchcik | a930fbe | 2006-01-09 16:28:20 +0000 | [diff] [blame] | 151 | XMLPUBFUN void XMLCALL |
| 152 | xmlRelaxNGSetParserStructuredErrors( |
| 153 | xmlRelaxNGParserCtxtPtr ctxt, |
| 154 | xmlStructuredErrorFunc serror, |
| 155 | void *ctx); |
Daniel Veillard | f63085d | 2009-01-18 20:53:59 +0000 | [diff] [blame] | 156 | XMLPUBFUN xmlRelaxNGPtr XMLCALL |
Igor Zlatkovic | 93f984a | 2003-08-25 10:34:41 +0000 | [diff] [blame] | 157 | xmlRelaxNGParse (xmlRelaxNGParserCtxtPtr ctxt); |
Daniel Veillard | f63085d | 2009-01-18 20:53:59 +0000 | [diff] [blame] | 158 | XMLPUBFUN void XMLCALL |
Igor Zlatkovic | 93f984a | 2003-08-25 10:34:41 +0000 | [diff] [blame] | 159 | xmlRelaxNGFree (xmlRelaxNGPtr schema); |
Daniel Veillard | a9cce9c | 2003-09-29 13:20:24 +0000 | [diff] [blame] | 160 | #ifdef LIBXML_OUTPUT_ENABLED |
Daniel Veillard | f63085d | 2009-01-18 20:53:59 +0000 | [diff] [blame] | 161 | XMLPUBFUN void XMLCALL |
Igor Zlatkovic | 93f984a | 2003-08-25 10:34:41 +0000 | [diff] [blame] | 162 | xmlRelaxNGDump (FILE *output, |
Daniel Veillard | 6eadf63 | 2003-01-23 18:29:16 +0000 | [diff] [blame] | 163 | xmlRelaxNGPtr schema); |
Igor Zlatkovic | 93f984a | 2003-08-25 10:34:41 +0000 | [diff] [blame] | 164 | XMLPUBFUN void XMLCALL |
| 165 | xmlRelaxNGDumpTree (FILE * output, |
Daniel Veillard | febcca4 | 2003-02-16 15:44:18 +0000 | [diff] [blame] | 166 | xmlRelaxNGPtr schema); |
Daniel Veillard | a9cce9c | 2003-09-29 13:20:24 +0000 | [diff] [blame] | 167 | #endif /* LIBXML_OUTPUT_ENABLED */ |
Daniel Veillard | 6eadf63 | 2003-01-23 18:29:16 +0000 | [diff] [blame] | 168 | /* |
| 169 | * Interfaces for validating |
| 170 | */ |
Daniel Veillard | f63085d | 2009-01-18 20:53:59 +0000 | [diff] [blame] | 171 | XMLPUBFUN void XMLCALL |
Igor Zlatkovic | 93f984a | 2003-08-25 10:34:41 +0000 | [diff] [blame] | 172 | xmlRelaxNGSetValidErrors(xmlRelaxNGValidCtxtPtr ctxt, |
Daniel Veillard | 6eadf63 | 2003-01-23 18:29:16 +0000 | [diff] [blame] | 173 | xmlRelaxNGValidityErrorFunc err, |
| 174 | xmlRelaxNGValidityWarningFunc warn, |
| 175 | void *ctx); |
Daniel Veillard | f63085d | 2009-01-18 20:53:59 +0000 | [diff] [blame] | 176 | XMLPUBFUN int XMLCALL |
Igor Zlatkovic | 93f984a | 2003-08-25 10:34:41 +0000 | [diff] [blame] | 177 | xmlRelaxNGGetValidErrors(xmlRelaxNGValidCtxtPtr ctxt, |
Daniel Veillard | 409a814 | 2003-07-18 15:16:57 +0000 | [diff] [blame] | 178 | xmlRelaxNGValidityErrorFunc *err, |
| 179 | xmlRelaxNGValidityWarningFunc *warn, |
| 180 | void **ctx); |
Daniel Veillard | da0aa4c | 2005-07-13 23:07:49 +0000 | [diff] [blame] | 181 | XMLPUBFUN void XMLCALL |
| 182 | xmlRelaxNGSetValidStructuredErrors(xmlRelaxNGValidCtxtPtr ctxt, |
| 183 | xmlStructuredErrorFunc serror, void *ctx); |
Daniel Veillard | f63085d | 2009-01-18 20:53:59 +0000 | [diff] [blame] | 184 | XMLPUBFUN xmlRelaxNGValidCtxtPtr XMLCALL |
Igor Zlatkovic | 93f984a | 2003-08-25 10:34:41 +0000 | [diff] [blame] | 185 | xmlRelaxNGNewValidCtxt (xmlRelaxNGPtr schema); |
Daniel Veillard | f63085d | 2009-01-18 20:53:59 +0000 | [diff] [blame] | 186 | XMLPUBFUN void XMLCALL |
Igor Zlatkovic | 93f984a | 2003-08-25 10:34:41 +0000 | [diff] [blame] | 187 | xmlRelaxNGFreeValidCtxt (xmlRelaxNGValidCtxtPtr ctxt); |
Daniel Veillard | f63085d | 2009-01-18 20:53:59 +0000 | [diff] [blame] | 188 | XMLPUBFUN int XMLCALL |
Igor Zlatkovic | 93f984a | 2003-08-25 10:34:41 +0000 | [diff] [blame] | 189 | xmlRelaxNGValidateDoc (xmlRelaxNGValidCtxtPtr ctxt, |
Daniel Veillard | f63085d | 2009-01-18 20:53:59 +0000 | [diff] [blame] | 190 | xmlDocPtr doc); |
Daniel Veillard | f4e5576 | 2003-04-15 23:32:22 +0000 | [diff] [blame] | 191 | /* |
| 192 | * Interfaces for progressive validation when possible |
| 193 | */ |
Daniel Veillard | f63085d | 2009-01-18 20:53:59 +0000 | [diff] [blame] | 194 | XMLPUBFUN int XMLCALL |
Igor Zlatkovic | 93f984a | 2003-08-25 10:34:41 +0000 | [diff] [blame] | 195 | xmlRelaxNGValidatePushElement (xmlRelaxNGValidCtxtPtr ctxt, |
Daniel Veillard | f4e5576 | 2003-04-15 23:32:22 +0000 | [diff] [blame] | 196 | xmlDocPtr doc, |
| 197 | xmlNodePtr elem); |
Daniel Veillard | f63085d | 2009-01-18 20:53:59 +0000 | [diff] [blame] | 198 | XMLPUBFUN int XMLCALL |
Igor Zlatkovic | 93f984a | 2003-08-25 10:34:41 +0000 | [diff] [blame] | 199 | xmlRelaxNGValidatePushCData (xmlRelaxNGValidCtxtPtr ctxt, |
Daniel Veillard | f4e5576 | 2003-04-15 23:32:22 +0000 | [diff] [blame] | 200 | const xmlChar *data, |
| 201 | int len); |
Daniel Veillard | f63085d | 2009-01-18 20:53:59 +0000 | [diff] [blame] | 202 | XMLPUBFUN int XMLCALL |
Igor Zlatkovic | 93f984a | 2003-08-25 10:34:41 +0000 | [diff] [blame] | 203 | xmlRelaxNGValidatePopElement (xmlRelaxNGValidCtxtPtr ctxt, |
Daniel Veillard | f4e5576 | 2003-04-15 23:32:22 +0000 | [diff] [blame] | 204 | xmlDocPtr doc, |
| 205 | xmlNodePtr elem); |
Daniel Veillard | f63085d | 2009-01-18 20:53:59 +0000 | [diff] [blame] | 206 | XMLPUBFUN int XMLCALL |
Igor Zlatkovic | 93f984a | 2003-08-25 10:34:41 +0000 | [diff] [blame] | 207 | xmlRelaxNGValidateFullElement (xmlRelaxNGValidCtxtPtr ctxt, |
Daniel Veillard | f4e5576 | 2003-04-15 23:32:22 +0000 | [diff] [blame] | 208 | xmlDocPtr doc, |
| 209 | xmlNodePtr elem); |
Daniel Veillard | 94394cd | 2003-10-29 17:07:51 +0000 | [diff] [blame] | 210 | |
| 211 | #ifdef __cplusplus |
| 212 | } |
| 213 | #endif |
Daniel Veillard | a235132 | 2004-06-27 12:08:10 +0000 | [diff] [blame] | 214 | |
| 215 | #endif /* LIBXML_SCHEMAS_ENABLED */ |
| 216 | |
Daniel Veillard | 6eadf63 | 2003-01-23 18:29:16 +0000 | [diff] [blame] | 217 | #endif /* __XML_RELAX_NG__ */ |