Initial revision
[TestXSLT.git] / libxml2 / include / libxml / xmlschemas.h
1 /*
2  * schemas.h : interface to the XML Schemas handling and schema validity
3  *             checking
4  *
5  * See Copyright for the status of this software.
6  *
7  * Daniel.Veillard@w3.org
8  */
9
10
11 #ifndef __XML_SCHEMA_H__
12 #define __XML_SCHEMA_H__
13
14 #include <libxml/xmlversion.h>
15
16 #ifdef LIBXML_SCHEMAS_ENABLED
17
18 #include <libxml/tree.h>
19
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23
24 typedef enum {
25     XML_SCHEMAS_ERR_OK          = 0,
26     XML_SCHEMAS_ERR_NOROOT      = 1,
27     XML_SCHEMAS_ERR_UNDECLAREDELEM,
28     XML_SCHEMAS_ERR_NOTTOPLEVEL,
29     XML_SCHEMAS_ERR_MISSING,
30     XML_SCHEMAS_ERR_WRONGELEM,
31     XML_SCHEMAS_ERR_NOTYPE,
32     XML_SCHEMAS_ERR_NOROLLBACK,
33     XML_SCHEMAS_ERR_ISABSTRACT,
34     XML_SCHEMAS_ERR_NOTEMPTY,
35     XML_SCHEMAS_ERR_ELEMCONT,
36     XML_SCHEMAS_ERR_HAVEDEFAULT,
37     XML_SCHEMAS_ERR_NOTNILLABLE,
38     XML_SCHEMAS_ERR_EXTRACONTENT,
39     XML_SCHEMAS_ERR_INVALIDATTR,
40     XML_SCHEMAS_ERR_INVALIDELEM,
41     XML_SCHEMAS_ERR_NOTDETERMINIST,
42     XML_SCHEMAS_ERR_CONSTRUCT,
43     XML_SCHEMAS_ERR_INTERNAL,
44     XML_SCHEMAS_ERR_NOTSIMPLE,
45     XML_SCHEMAS_ERR_ATTRUNKNOWN,
46     XML_SCHEMAS_ERR_ATTRINVALID,
47     XML_SCHEMAS_ERR_,
48     XML_SCHEMAS_ERR_XXX
49 } xmlSchemaValidError;
50
51
52 /**
53  * The schemas related types are kept internal
54  */
55 typedef struct _xmlSchema xmlSchema;
56 typedef xmlSchema *xmlSchemaPtr;
57
58 /**
59  * A schemas validation context
60  */
61 typedef void (*xmlSchemaValidityErrorFunc) (void *ctx, const char *msg, ...);
62 typedef void (*xmlSchemaValidityWarningFunc) (void *ctx, const char *msg, ...);
63
64 typedef struct _xmlSchemaParserCtxt xmlSchemaParserCtxt;
65 typedef xmlSchemaParserCtxt *xmlSchemaParserCtxtPtr;
66
67 typedef struct _xmlSchemaValidCtxt xmlSchemaValidCtxt;
68 typedef xmlSchemaValidCtxt *xmlSchemaValidCtxtPtr;
69
70 /*
71  * Interfaces for parsing.
72  */
73 xmlSchemaParserCtxtPtr xmlSchemaNewParserCtxt   (const char *URL);
74 xmlSchemaParserCtxtPtr xmlSchemaNewMemParserCtxt(const char *buffer,
75                                                  int size);
76 void            xmlSchemaFreeParserCtxt (xmlSchemaParserCtxtPtr ctxt);
77 void            xmlSchemaSetParserErrors(xmlSchemaParserCtxtPtr ctxt,
78                                          xmlSchemaValidityErrorFunc err,
79                                          xmlSchemaValidityWarningFunc warn,
80                                          void *ctx);
81 xmlSchemaPtr    xmlSchemaParse          (xmlSchemaParserCtxtPtr ctxt);
82 void            xmlSchemaFree           (xmlSchemaPtr schema);
83 void            xmlSchemaDump           (FILE *output,
84                                          xmlSchemaPtr schema);
85 /*
86  * Interfaces for validating
87  */
88 void            xmlSchemaSetValidErrors (xmlSchemaValidCtxtPtr ctxt,
89                                          xmlSchemaValidityErrorFunc err,
90                                          xmlSchemaValidityWarningFunc warn,
91                                          void *ctx);
92 xmlSchemaValidCtxtPtr   xmlSchemaNewValidCtxt   (xmlSchemaPtr schema);
93 void                    xmlSchemaFreeValidCtxt  (xmlSchemaValidCtxtPtr ctxt);
94 int                     xmlSchemaValidateDoc    (xmlSchemaValidCtxtPtr ctxt,
95                                                  xmlDocPtr instance);
96 int                     xmlSchemaValidateStream (xmlSchemaValidCtxtPtr ctxt,
97                                                  xmlParserInputBufferPtr input,
98                                                  xmlCharEncoding enc,
99                                                  xmlSAXHandlerPtr sax,
100                                                  void *user_data);
101 #ifdef __cplusplus
102 }
103 #endif
104
105 #endif /* LIBXML_SCHEMAS_ENABLED */
106 #endif /* __XML_SCHEMA_H__ */