2 * Summary: incomplete XML Schemas structure implementation
3 * Description: interface to the XML Schemas handling and schema validity
4 * checking, it is incomplete right now.
6 * Copy: See Copyright for the status of this software.
8 * Author: Daniel Veillard
12 #ifndef __XML_SCHEMA_H__
13 #define __XML_SCHEMA_H__
15 #include <libxml/xmlversion.h>
17 #ifdef LIBXML_SCHEMAS_ENABLED
19 #include <libxml/tree.h>
26 * This error codes are obsolete; not used any more.
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,
39 XML_SCHEMAS_ERR_ELEMCONT,
40 XML_SCHEMAS_ERR_HAVEDEFAULT,
41 XML_SCHEMAS_ERR_NOTNILLABLE,
42 XML_SCHEMAS_ERR_EXTRACONTENT,
43 XML_SCHEMAS_ERR_INVALIDATTR,
44 XML_SCHEMAS_ERR_INVALIDELEM,
45 XML_SCHEMAS_ERR_NOTDETERMINIST,
46 XML_SCHEMAS_ERR_CONSTRUCT,
47 XML_SCHEMAS_ERR_INTERNAL,
48 XML_SCHEMAS_ERR_NOTSIMPLE,
49 XML_SCHEMAS_ERR_ATTRUNKNOWN,
50 XML_SCHEMAS_ERR_ATTRINVALID,
51 XML_SCHEMAS_ERR_VALUE,
52 XML_SCHEMAS_ERR_FACET,
55 } xmlSchemaValidError;
58 * ATTENTION: Change xmlSchemaSetValidOptions's check
59 * for invalid values, if adding to the validation
63 * xmlSchemaValidOption:
65 * This is the set of XML Schema validation options.
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.
72 } xmlSchemaValidOption;
75 XML_SCHEMA_VAL_XSI_ASSEMBLE = 1<<1,
76 * assemble schemata using
77 * xsi:schemaLocation and
78 * xsi:noNamespaceSchemaLocation
82 * The schemas related types are kept internal
84 typedef struct _xmlSchema xmlSchema;
85 typedef xmlSchema *xmlSchemaPtr;
88 * xmlSchemaValidityErrorFunc:
89 * @ctx: the validation context
91 * @...: extra arguments
93 * Signature of an error callback from an XSD validation
95 typedef void (XMLCDECL *xmlSchemaValidityErrorFunc)
96 (void *ctx, const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);
99 * xmlSchemaValidityWarningFunc:
100 * @ctx: the validation context
102 * @...: extra arguments
104 * Signature of a warning callback from an XSD validation
106 typedef void (XMLCDECL *xmlSchemaValidityWarningFunc)
107 (void *ctx, const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);
110 * A schemas validation context
112 typedef struct _xmlSchemaParserCtxt xmlSchemaParserCtxt;
113 typedef xmlSchemaParserCtxt *xmlSchemaParserCtxtPtr;
115 typedef struct _xmlSchemaValidCtxt xmlSchemaValidCtxt;
116 typedef xmlSchemaValidCtxt *xmlSchemaValidCtxtPtr;
119 * xmlSchemaValidityLocatorFunc:
120 * @ctx: user provided context
121 * @file: returned file information
122 * @line: returned line information
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
128 * Returns: 0 in case of success and -1 in case of error
131 typedef int (XMLCDECL *xmlSchemaValidityLocatorFunc) (void *ctx,
132 const char **file, unsigned long *line);
135 * Interfaces for parsing.
137 XMLPUBFUN xmlSchemaParserCtxtPtr XMLCALL
138 xmlSchemaNewParserCtxt (const char *URL);
139 XMLPUBFUN xmlSchemaParserCtxtPtr XMLCALL
140 xmlSchemaNewMemParserCtxt (const char *buffer,
142 XMLPUBFUN xmlSchemaParserCtxtPtr XMLCALL
143 xmlSchemaNewDocParserCtxt (xmlDocPtr doc);
144 XMLPUBFUN void XMLCALL
145 xmlSchemaFreeParserCtxt (xmlSchemaParserCtxtPtr ctxt);
146 XMLPUBFUN void XMLCALL
147 xmlSchemaSetParserErrors (xmlSchemaParserCtxtPtr ctxt,
148 xmlSchemaValidityErrorFunc err,
149 xmlSchemaValidityWarningFunc warn,
151 XMLPUBFUN void XMLCALL
152 xmlSchemaSetParserStructuredErrors(xmlSchemaParserCtxtPtr ctxt,
153 xmlStructuredErrorFunc serror,
155 XMLPUBFUN int XMLCALL
156 xmlSchemaGetParserErrors(xmlSchemaParserCtxtPtr ctxt,
157 xmlSchemaValidityErrorFunc * err,
158 xmlSchemaValidityWarningFunc * warn,
160 XMLPUBFUN int XMLCALL
161 xmlSchemaIsValid (xmlSchemaValidCtxtPtr ctxt);
163 XMLPUBFUN xmlSchemaPtr XMLCALL
164 xmlSchemaParse (xmlSchemaParserCtxtPtr ctxt);
165 XMLPUBFUN void XMLCALL
166 xmlSchemaFree (xmlSchemaPtr schema);
167 #ifdef LIBXML_OUTPUT_ENABLED
168 XMLPUBFUN void XMLCALL
169 xmlSchemaDump (FILE *output,
170 xmlSchemaPtr schema);
171 #endif /* LIBXML_OUTPUT_ENABLED */
173 * Interfaces for validating
175 XMLPUBFUN void XMLCALL
176 xmlSchemaSetValidErrors (xmlSchemaValidCtxtPtr ctxt,
177 xmlSchemaValidityErrorFunc err,
178 xmlSchemaValidityWarningFunc warn,
180 XMLPUBFUN void XMLCALL
181 xmlSchemaSetValidStructuredErrors(xmlSchemaValidCtxtPtr ctxt,
182 xmlStructuredErrorFunc serror,
184 XMLPUBFUN int XMLCALL
185 xmlSchemaGetValidErrors (xmlSchemaValidCtxtPtr ctxt,
186 xmlSchemaValidityErrorFunc *err,
187 xmlSchemaValidityWarningFunc *warn,
189 XMLPUBFUN int XMLCALL
190 xmlSchemaSetValidOptions (xmlSchemaValidCtxtPtr ctxt,
192 XMLPUBFUN void XMLCALL
193 xmlSchemaValidateSetFilename(xmlSchemaValidCtxtPtr vctxt,
194 const char *filename);
195 XMLPUBFUN int XMLCALL
196 xmlSchemaValidCtxtGetOptions(xmlSchemaValidCtxtPtr ctxt);
198 XMLPUBFUN xmlSchemaValidCtxtPtr XMLCALL
199 xmlSchemaNewValidCtxt (xmlSchemaPtr schema);
200 XMLPUBFUN void XMLCALL
201 xmlSchemaFreeValidCtxt (xmlSchemaValidCtxtPtr ctxt);
202 XMLPUBFUN int XMLCALL
203 xmlSchemaValidateDoc (xmlSchemaValidCtxtPtr ctxt,
205 XMLPUBFUN int XMLCALL
206 xmlSchemaValidateOneElement (xmlSchemaValidCtxtPtr ctxt,
208 XMLPUBFUN int XMLCALL
209 xmlSchemaValidateStream (xmlSchemaValidCtxtPtr ctxt,
210 xmlParserInputBufferPtr input,
212 xmlSAXHandlerPtr sax,
214 XMLPUBFUN int XMLCALL
215 xmlSchemaValidateFile (xmlSchemaValidCtxtPtr ctxt,
216 const char * filename,
219 XMLPUBFUN xmlParserCtxtPtr XMLCALL
220 xmlSchemaValidCtxtGetParserCtxt(xmlSchemaValidCtxtPtr ctxt);
223 * Interface to insert Schemas SAX validation in a SAX stream
225 typedef struct _xmlSchemaSAXPlug xmlSchemaSAXPlugStruct;
226 typedef xmlSchemaSAXPlugStruct *xmlSchemaSAXPlugPtr;
228 XMLPUBFUN xmlSchemaSAXPlugPtr XMLCALL
229 xmlSchemaSAXPlug (xmlSchemaValidCtxtPtr ctxt,
230 xmlSAXHandlerPtr *sax,
232 XMLPUBFUN int XMLCALL
233 xmlSchemaSAXUnplug (xmlSchemaSAXPlugPtr plug);
236 XMLPUBFUN void XMLCALL
237 xmlSchemaValidateSetLocator (xmlSchemaValidCtxtPtr vctxt,
238 xmlSchemaValidityLocatorFunc f,
245 #endif /* LIBXML_SCHEMAS_ENABLED */
246 #endif /* __XML_SCHEMA_H__ */