blob: 97930c7c3f4c1f1f4f021d8cd75474709474c6f9 [file] [log] [blame]
Daniel Veillard4255d502002-04-16 15:50:10 +00001/*
Daniel Veillardbe586972003-11-18 20:56:51 +00002 * Summary: incomplete XML Schemas structure implementation
3 * Description: interface to the XML Schemas handling and schema validity
4 * checking, it is incomplete right now.
Daniel Veillard4255d502002-04-16 15:50:10 +00005 *
Daniel Veillardbe586972003-11-18 20:56:51 +00006 * Copy: See Copyright for the status of this software.
Daniel Veillard4255d502002-04-16 15:50:10 +00007 *
Daniel Veillardbe586972003-11-18 20:56:51 +00008 * Author: Daniel Veillard
Daniel Veillard4255d502002-04-16 15:50:10 +00009 */
10
11
12#ifndef __XML_SCHEMA_H__
13#define __XML_SCHEMA_H__
14
Daniel Veillard4255d502002-04-16 15:50:10 +000015#include <libxml/xmlversion.h>
Igor Zlatkovic7ae91bc2002-11-08 17:18:52 +000016
Daniel Veillard4255d502002-04-16 15:50:10 +000017#ifdef LIBXML_SCHEMAS_ENABLED
18
19#include <libxml/tree.h>
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
Kasimier T. Buchcikbea23542004-08-25 20:35:45 +000025/**
26 * This error codes are obsolete; not used any more.
27 */
Daniel Veillard4255d502002-04-16 15:50:10 +000028typedef enum {
29 XML_SCHEMAS_ERR_OK = 0,
30 XML_SCHEMAS_ERR_NOROOT = 1,
31 XML_SCHEMAS_ERR_UNDECLAREDELEM,
32 XML_SCHEMAS_ERR_NOTTOPLEVEL,
33 XML_SCHEMAS_ERR_MISSING,
34 XML_SCHEMAS_ERR_WRONGELEM,
35 XML_SCHEMAS_ERR_NOTYPE,
36 XML_SCHEMAS_ERR_NOROLLBACK,
37 XML_SCHEMAS_ERR_ISABSTRACT,
38 XML_SCHEMAS_ERR_NOTEMPTY,
Daniel Veillard8651f532002-04-17 09:06:27 +000039 XML_SCHEMAS_ERR_ELEMCONT,
Daniel Veillard4255d502002-04-16 15:50:10 +000040 XML_SCHEMAS_ERR_HAVEDEFAULT,
41 XML_SCHEMAS_ERR_NOTNILLABLE,
42 XML_SCHEMAS_ERR_EXTRACONTENT,
43 XML_SCHEMAS_ERR_INVALIDATTR,
44 XML_SCHEMAS_ERR_INVALIDELEM,
Daniel Veillarde19fc232002-04-22 16:01:24 +000045 XML_SCHEMAS_ERR_NOTDETERMINIST,
Daniel Veillard4255d502002-04-16 15:50:10 +000046 XML_SCHEMAS_ERR_CONSTRUCT,
47 XML_SCHEMAS_ERR_INTERNAL,
48 XML_SCHEMAS_ERR_NOTSIMPLE,
49 XML_SCHEMAS_ERR_ATTRUNKNOWN,
50 XML_SCHEMAS_ERR_ATTRINVALID,
Daniel Veillard91a13252003-03-27 23:44:43 +000051 XML_SCHEMAS_ERR_VALUE,
Daniel Veillardd3b9cd82003-04-09 11:24:17 +000052 XML_SCHEMAS_ERR_FACET,
Daniel Veillard4255d502002-04-16 15:50:10 +000053 XML_SCHEMAS_ERR_,
54 XML_SCHEMAS_ERR_XXX
55} xmlSchemaValidError;
56
Kasimier T. Buchcik87876402004-09-29 13:29:03 +000057/*
58* ATTENTION: Change xmlSchemaSetValidOptions's check
Daniel Veillarddee23482008-04-11 12:58:43 +000059* for invalid values, if adding to the validation
Kasimier T. Buchcik87876402004-09-29 13:29:03 +000060* options below.
61*/
62/**
63 * xmlSchemaValidOption:
64 *
65 * This is the set of XML Schema validation options.
66 */
67typedef enum {
68 XML_SCHEMA_VAL_VC_I_CREATE = 1<<0
69 /* Default/fixed: create an attribute node
70 * or an element's text node on the instance.
71 */
72} xmlSchemaValidOption;
73
74/*
75 XML_SCHEMA_VAL_XSI_ASSEMBLE = 1<<1,
76 * assemble schemata using
77 * xsi:schemaLocation and
78 * xsi:noNamespaceSchemaLocation
79*/
Daniel Veillard4255d502002-04-16 15:50:10 +000080
81/**
82 * The schemas related types are kept internal
83 */
84typedef struct _xmlSchema xmlSchema;
85typedef xmlSchema *xmlSchemaPtr;
86
87/**
Daniel Veillarddee23482008-04-11 12:58:43 +000088 * xmlSchemaValidityErrorFunc:
89 * @ctx: the validation context
90 * @msg: the message
91 * @...: extra arguments
92 *
93 * Signature of an error callback from an XSD validation
Daniel Veillard4255d502002-04-16 15:50:10 +000094 */
Daniel Veillardf8e3db02012-09-11 13:26:36 +080095typedef void (XMLCDECL *xmlSchemaValidityErrorFunc)
96 (void *ctx, const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);
Daniel Veillarddee23482008-04-11 12:58:43 +000097
98/**
99 * xmlSchemaValidityWarningFunc:
100 * @ctx: the validation context
101 * @msg: the message
102 * @...: extra arguments
103 *
104 * Signature of a warning callback from an XSD validation
105 */
Daniel Veillardf8e3db02012-09-11 13:26:36 +0800106typedef void (XMLCDECL *xmlSchemaValidityWarningFunc)
107 (void *ctx, const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);
Daniel Veillard4255d502002-04-16 15:50:10 +0000108
Daniel Veillarddee23482008-04-11 12:58:43 +0000109/**
110 * A schemas validation context
111 */
Daniel Veillard4255d502002-04-16 15:50:10 +0000112typedef struct _xmlSchemaParserCtxt xmlSchemaParserCtxt;
113typedef xmlSchemaParserCtxt *xmlSchemaParserCtxtPtr;
114
115typedef struct _xmlSchemaValidCtxt xmlSchemaValidCtxt;
116typedef xmlSchemaValidCtxt *xmlSchemaValidCtxtPtr;
117
Daniel Veillard97fa5b32012-08-14 11:01:07 +0800118/**
119 * xmlSchemaValidityLocatorFunc:
120 * @ctx: user provided context
121 * @file: returned file information
122 * @line: returned line information
123 *
124 * A schemas validation locator, a callback called by the validator.
125 * This is used when file or node informations are not available
126 * to find out what file and line number are affected
127 *
128 * Returns: 0 in case of success and -1 in case of error
129 */
130
131typedef int (XMLCDECL *xmlSchemaValidityLocatorFunc) (void *ctx,
132 const char **file, unsigned long *line);
133
Daniel Veillard4255d502002-04-16 15:50:10 +0000134/*
135 * Interfaces for parsing.
136 */
Daniel Veillarddee23482008-04-11 12:58:43 +0000137XMLPUBFUN xmlSchemaParserCtxtPtr XMLCALL
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000138 xmlSchemaNewParserCtxt (const char *URL);
Daniel Veillarddee23482008-04-11 12:58:43 +0000139XMLPUBFUN xmlSchemaParserCtxtPtr XMLCALL
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000140 xmlSchemaNewMemParserCtxt (const char *buffer,
141 int size);
Daniel Veillard9d751502003-10-29 13:21:47 +0000142XMLPUBFUN xmlSchemaParserCtxtPtr XMLCALL
143 xmlSchemaNewDocParserCtxt (xmlDocPtr doc);
Daniel Veillarddee23482008-04-11 12:58:43 +0000144XMLPUBFUN void XMLCALL
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000145 xmlSchemaFreeParserCtxt (xmlSchemaParserCtxtPtr ctxt);
Daniel Veillarddee23482008-04-11 12:58:43 +0000146XMLPUBFUN void XMLCALL
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000147 xmlSchemaSetParserErrors (xmlSchemaParserCtxtPtr ctxt,
Daniel Veillard4255d502002-04-16 15:50:10 +0000148 xmlSchemaValidityErrorFunc err,
149 xmlSchemaValidityWarningFunc warn,
150 void *ctx);
Kasimier T. Buchcik90b5ebc2005-11-18 17:18:27 +0000151XMLPUBFUN void XMLCALL
152 xmlSchemaSetParserStructuredErrors(xmlSchemaParserCtxtPtr ctxt,
153 xmlStructuredErrorFunc serror,
154 void *ctx);
Daniel Veillard259f0df2004-08-18 09:13:18 +0000155XMLPUBFUN int XMLCALL
Daniel Veillardf10ae122005-07-10 19:03:16 +0000156 xmlSchemaGetParserErrors(xmlSchemaParserCtxtPtr ctxt,
Daniel Veillard259f0df2004-08-18 09:13:18 +0000157 xmlSchemaValidityErrorFunc * err,
158 xmlSchemaValidityWarningFunc * warn,
159 void **ctx);
Daniel Veillardf10ae122005-07-10 19:03:16 +0000160XMLPUBFUN int XMLCALL
161 xmlSchemaIsValid (xmlSchemaValidCtxtPtr ctxt);
162
Daniel Veillarddee23482008-04-11 12:58:43 +0000163XMLPUBFUN xmlSchemaPtr XMLCALL
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000164 xmlSchemaParse (xmlSchemaParserCtxtPtr ctxt);
Daniel Veillarddee23482008-04-11 12:58:43 +0000165XMLPUBFUN void XMLCALL
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000166 xmlSchemaFree (xmlSchemaPtr schema);
Daniel Veillarda9cce9c2003-09-29 13:20:24 +0000167#ifdef LIBXML_OUTPUT_ENABLED
Daniel Veillarddee23482008-04-11 12:58:43 +0000168XMLPUBFUN void XMLCALL
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000169 xmlSchemaDump (FILE *output,
Daniel Veillard4255d502002-04-16 15:50:10 +0000170 xmlSchemaPtr schema);
Daniel Veillarda9cce9c2003-09-29 13:20:24 +0000171#endif /* LIBXML_OUTPUT_ENABLED */
Daniel Veillard4255d502002-04-16 15:50:10 +0000172/*
173 * Interfaces for validating
174 */
Daniel Veillarddee23482008-04-11 12:58:43 +0000175XMLPUBFUN void XMLCALL
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000176 xmlSchemaSetValidErrors (xmlSchemaValidCtxtPtr ctxt,
Daniel Veillard4255d502002-04-16 15:50:10 +0000177 xmlSchemaValidityErrorFunc err,
178 xmlSchemaValidityWarningFunc warn,
179 void *ctx);
Daniel Veillardda0aa4c2005-07-13 23:07:49 +0000180XMLPUBFUN void XMLCALL
181 xmlSchemaSetValidStructuredErrors(xmlSchemaValidCtxtPtr ctxt,
Kasimier T. Buchcik90b5ebc2005-11-18 17:18:27 +0000182 xmlStructuredErrorFunc serror,
183 void *ctx);
Daniel Veillard259f0df2004-08-18 09:13:18 +0000184XMLPUBFUN int XMLCALL
Kasimier T. Buchcik87876402004-09-29 13:29:03 +0000185 xmlSchemaGetValidErrors (xmlSchemaValidCtxtPtr ctxt,
186 xmlSchemaValidityErrorFunc *err,
187 xmlSchemaValidityWarningFunc *warn,
188 void **ctx);
189XMLPUBFUN int XMLCALL
190 xmlSchemaSetValidOptions (xmlSchemaValidCtxtPtr ctxt,
191 int options);
Daniel Veillard97fa5b32012-08-14 11:01:07 +0800192XMLPUBFUN void XMLCALL
193 xmlSchemaValidateSetFilename(xmlSchemaValidCtxtPtr vctxt,
194 const char *filename);
Kasimier T. Buchcik87876402004-09-29 13:29:03 +0000195XMLPUBFUN int XMLCALL
196 xmlSchemaValidCtxtGetOptions(xmlSchemaValidCtxtPtr ctxt);
Daniel Veillard259f0df2004-08-18 09:13:18 +0000197
Daniel Veillarddee23482008-04-11 12:58:43 +0000198XMLPUBFUN xmlSchemaValidCtxtPtr XMLCALL
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000199 xmlSchemaNewValidCtxt (xmlSchemaPtr schema);
Daniel Veillarddee23482008-04-11 12:58:43 +0000200XMLPUBFUN void XMLCALL
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000201 xmlSchemaFreeValidCtxt (xmlSchemaValidCtxtPtr ctxt);
Daniel Veillarddee23482008-04-11 12:58:43 +0000202XMLPUBFUN int XMLCALL
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000203 xmlSchemaValidateDoc (xmlSchemaValidCtxtPtr ctxt,
204 xmlDocPtr instance);
Kasimier T. Buchcik5eba91f2004-09-08 09:17:27 +0000205XMLPUBFUN int XMLCALL
206 xmlSchemaValidateOneElement (xmlSchemaValidCtxtPtr ctxt,
207 xmlNodePtr elem);
Kasimier T. Buchcikc63fbbf2005-06-15 12:54:05 +0000208XMLPUBFUN int XMLCALL
Igor Zlatkovicaa3cfbd2003-08-27 08:59:58 +0000209 xmlSchemaValidateStream (xmlSchemaValidCtxtPtr ctxt,
210 xmlParserInputBufferPtr input,
211 xmlCharEncoding enc,
212 xmlSAXHandlerPtr sax,
213 void *user_data);
Kasimier T. Buchcikc63fbbf2005-06-15 12:54:05 +0000214XMLPUBFUN int XMLCALL
215 xmlSchemaValidateFile (xmlSchemaValidCtxtPtr ctxt,
216 const char * filename,
217 int options);
Daniel Veillard971771e2005-07-09 17:32:57 +0000218
Daniel Veillarddee23482008-04-11 12:58:43 +0000219XMLPUBFUN xmlParserCtxtPtr XMLCALL
220 xmlSchemaValidCtxtGetParserCtxt(xmlSchemaValidCtxtPtr ctxt);
221
Daniel Veillard971771e2005-07-09 17:32:57 +0000222/*
Daniel Veillarddee23482008-04-11 12:58:43 +0000223 * Interface to insert Schemas SAX validation in a SAX stream
Daniel Veillard971771e2005-07-09 17:32:57 +0000224 */
225typedef struct _xmlSchemaSAXPlug xmlSchemaSAXPlugStruct;
226typedef xmlSchemaSAXPlugStruct *xmlSchemaSAXPlugPtr;
227
228XMLPUBFUN xmlSchemaSAXPlugPtr XMLCALL
229 xmlSchemaSAXPlug (xmlSchemaValidCtxtPtr ctxt,
230 xmlSAXHandlerPtr *sax,
231 void **user_data);
232XMLPUBFUN int XMLCALL
233 xmlSchemaSAXUnplug (xmlSchemaSAXPlugPtr plug);
Daniel Veillard97fa5b32012-08-14 11:01:07 +0800234
235
236XMLPUBFUN void XMLCALL
237 xmlSchemaValidateSetLocator (xmlSchemaValidCtxtPtr vctxt,
238 xmlSchemaValidityLocatorFunc f,
239 void *ctxt);
240
Daniel Veillard4255d502002-04-16 15:50:10 +0000241#ifdef __cplusplus
242}
243#endif
244
245#endif /* LIBXML_SCHEMAS_ENABLED */
246#endif /* __XML_SCHEMA_H__ */