blob: cd14fb2ac5bd7b206ca59c39b64763ebd41ed721 [file] [log] [blame]
Daniel Veillard4255d502002-04-16 15:50:10 +00001/*
2 * schemasInternals.h : internal interfaces for the XML Schemas handling
3 * and schema validity checking
4 *
5 * See Copyright for the status of this software.
6 *
7 * Daniel.Veillard@w3.org
8 */
9
10
11#ifndef __XML_SCHEMA_INTERNALS_H__
12#define __XML_SCHEMA_INTERNALS_H__
13
14#if defined(WIN32) && defined(_MSC_VER)
15#include <libxml/xmlwin32version.h>
16#else
17#include <libxml/xmlversion.h>
18#endif
19#ifdef LIBXML_SCHEMAS_ENABLED
20
21#include <libxml/xmlregexp.h>
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27
28/*
29 * XML Schemas defines multiple type of types.
30 */
31typedef enum {
32 XML_SCHEMA_TYPE_BASIC = 1,
33 XML_SCHEMA_TYPE_ANY,
34 XML_SCHEMA_TYPE_FACET,
35 XML_SCHEMA_TYPE_SIMPLE,
36 XML_SCHEMA_TYPE_COMPLEX,
37 XML_SCHEMA_TYPE_SEQUENCE,
38 XML_SCHEMA_TYPE_CHOICE,
39 XML_SCHEMA_TYPE_ALL,
40 XML_SCHEMA_TYPE_SIMPLE_CONTENT,
41 XML_SCHEMA_TYPE_COMPLEX_CONTENT,
42 XML_SCHEMA_TYPE_UR,
43 XML_SCHEMA_TYPE_RESTRICTION,
44 XML_SCHEMA_TYPE_EXTENSION,
45 XML_SCHEMA_TYPE_ELEMENT,
46 XML_SCHEMA_TYPE_ATTRIBUTE,
Daniel Veillard13e04c62002-04-23 17:51:29 +000047 XML_SCHEMA_TYPE_ATTRIBUTEGROUP,
Daniel Veillard4255d502002-04-16 15:50:10 +000048 XML_SCHEMA_TYPE_GROUP,
49 XML_SCHEMA_TYPE_NOTATION,
50 XML_SCHEMA_TYPE_LIST,
51 XML_SCHEMA_TYPE_UNION,
52 XML_SCHEMA_FACET_MININCLUSIVE = 1000,
53 XML_SCHEMA_FACET_MINEXCLUSIVE,
54 XML_SCHEMA_FACET_MAXINCLUSIVE,
55 XML_SCHEMA_FACET_MAXEXCLUSIVE,
56 XML_SCHEMA_FACET_TOTALDIGITS,
57 XML_SCHEMA_FACET_FRACTIONDIGITS,
58 XML_SCHEMA_FACET_PATTERN,
59 XML_SCHEMA_FACET_ENUMERATION,
60 XML_SCHEMA_FACET_WHITESPACE,
61 XML_SCHEMA_FACET_LENGTH,
62 XML_SCHEMA_FACET_MAXLENGTH,
63 XML_SCHEMA_FACET_MINLENGTH
64} xmlSchemaTypeType;
65
66typedef enum {
67 XML_SCHEMA_CONTENT_UNKNOWN = 0,
68 XML_SCHEMA_CONTENT_EMPTY = 1,
69 XML_SCHEMA_CONTENT_ELEMENTS,
70 XML_SCHEMA_CONTENT_MIXED,
71 XML_SCHEMA_CONTENT_SIMPLE,
72 XML_SCHEMA_CONTENT_MIXED_OR_ELEMENTS,
Daniel Veillard88c58912002-04-23 07:12:20 +000073 XML_SCHEMA_CONTENT_BASIC,
74 XML_SCHEMA_CONTENT_ANY
Daniel Veillard4255d502002-04-16 15:50:10 +000075} xmlSchemaContentType;
76
77typedef struct _xmlSchemaVal xmlSchemaVal;
78typedef xmlSchemaVal *xmlSchemaValPtr;
79
80typedef struct _xmlSchemaType xmlSchemaType;
81typedef xmlSchemaType *xmlSchemaTypePtr;
82
83typedef struct _xmlSchemaFacet xmlSchemaFacet;
84typedef xmlSchemaFacet *xmlSchemaFacetPtr;
85
86/**
87 * Annotation
88 */
89typedef struct _xmlSchemaAnnot xmlSchemaAnnot;
90typedef xmlSchemaAnnot *xmlSchemaAnnotPtr;
91struct _xmlSchemaAnnot {
92 struct _xmlSchemaAnnot *next;
93 xmlNodePtr content; /* the annotation */
94};
95
96/**
97 * An attribute definition.
98 */
99
100#define XML_SCHEMAS_ANYATTR_SKIP 1
101#define XML_SCHEMAS_ANYATTR_LAX 2
102#define XML_SCHEMAS_ANYATTR_STRICT 3
103
104typedef struct _xmlSchemaAttribute xmlSchemaAttribute;
105typedef xmlSchemaAttribute *xmlSchemaAttributePtr;
106struct _xmlSchemaAttribute {
107 xmlSchemaTypeType type; /* The kind of type */
108 struct _xmlSchemaAttribute *next;/* the next attribute if in a group ... */
109 xmlChar *name;
110 xmlChar *id;
111 xmlChar *ref;
112 xmlChar *refNs;
113 xmlChar *typeName;
114 xmlChar *typeNs;
115 xmlSchemaAnnotPtr annot;
116
117 xmlSchemaTypePtr base;
118 int occurs;
119 xmlChar *defValue;
120 xmlSchemaTypePtr subtypes;
121};
122
123/**
124 * An attribute group definition.
125 *
126 * xmlSchemaAttribute and xmlSchemaAttributeGroup start of structures
127 * must be kept similar
128 */
129typedef struct _xmlSchemaAttributeGroup xmlSchemaAttributeGroup;
130typedef xmlSchemaAttributeGroup *xmlSchemaAttributeGroupPtr;
131struct _xmlSchemaAttributeGroup {
132 xmlSchemaTypeType type; /* The kind of type */
133 struct _xmlSchemaAttribute *next;/* the next attribute if in a group ... */
134 xmlChar *name;
135 xmlChar *id;
136 xmlChar *ref;
137 xmlChar *refNs;
138 xmlSchemaAnnotPtr annot;
139
140 xmlSchemaAttributePtr attributes;
141};
142
143
144/**
145 * Schemas type definition.
146 */
147#define XML_SCHEMAS_TYPE_MIXED 1 << 0
148
149struct _xmlSchemaType {
150 xmlSchemaTypeType type; /* The kind of type */
151 struct _xmlSchemaType *next;/* the next type if in a sequence ... */
152 xmlChar *name;
153 xmlChar *id;
154 xmlChar *ref;
155 xmlChar *refNs;
156 xmlSchemaAnnotPtr annot;
157 xmlSchemaTypePtr subtypes;
158 xmlSchemaAttributePtr attributes;
159 xmlNodePtr node;
160 int minOccurs;
161 int maxOccurs;
162
163 int flags;
164 xmlSchemaContentType contentType;
165 xmlChar *base;
166 xmlChar *baseNs;
167 xmlSchemaTypePtr baseType;
168 xmlSchemaFacetPtr facets;
169};
170
171/**
172 * An element definition.
173 *
174 * xmlSchemaType, xmlSchemaFacet and xmlSchemaElement start of
175 * structures must be kept similar
176 */
177#define XML_SCHEMAS_ELEM_NILLABLE 1 << 0
178#define XML_SCHEMAS_ELEM_GLOBAL 1 << 1
179#define XML_SCHEMAS_ELEM_DEFAULT 1 << 2
180#define XML_SCHEMAS_ELEM_FIXED 1 << 3
181#define XML_SCHEMAS_ELEM_ABSTRACT 1 << 4
182#define XML_SCHEMAS_ELEM_TOPLEVEL 1 << 5
183#define XML_SCHEMAS_ELEM_REF 1 << 6
184
185typedef struct _xmlSchemaElement xmlSchemaElement;
186typedef xmlSchemaElement *xmlSchemaElementPtr;
187struct _xmlSchemaElement {
188 xmlSchemaTypeType type; /* The kind of type */
189 struct _xmlSchemaType *next;/* the next type if in a sequence ... */
190 xmlChar *name;
191 xmlChar *id;
192 xmlChar *ref;
193 xmlChar *refNs;
194 xmlSchemaAnnotPtr annot;
195 xmlSchemaTypePtr subtypes;
196 xmlSchemaAttributePtr attributes;
197 xmlNodePtr node;
198 int minOccurs;
199 int maxOccurs;
200
201 int flags;
202 xmlChar *targetNamespace;
203 xmlChar *namedType;
204 xmlChar *namedTypeNs;
205 xmlChar *substGroup;
206 xmlChar *substGroupNs;
207 xmlChar *scope;
208 xmlChar *value;
209 struct _xmlSchemaElement *refDecl;
210 xmlRegexpPtr contModel;
Daniel Veillard88c58912002-04-23 07:12:20 +0000211 xmlSchemaContentType contentType;
Daniel Veillard4255d502002-04-16 15:50:10 +0000212};
213
214/**
215 * An facet definition.
216 *
217 */
218#define XML_SCHEMAS_FACET_UNKNOWN 0
219#define XML_SCHEMAS_FACET_PRESERVE 1
220#define XML_SCHEMAS_FACET_REPLACE 2
221#define XML_SCHEMAS_FACET_COLLAPSE 3
222
223struct _xmlSchemaFacet {
224 xmlSchemaTypeType type; /* The kind of type */
225 struct _xmlSchemaFacet *next;/* the next type if in a sequence ... */
226 xmlChar *value;
227 xmlChar *id;
228 xmlSchemaAnnotPtr annot;
229 xmlNodePtr node;
230 int fixed;
231 int whitespace;
232 xmlSchemaValPtr val;
233 xmlRegexpPtr regexp;
234};
235
236/**
237 * A notation definition.
238 */
239typedef struct _xmlSchemaNotation xmlSchemaNotation;
240typedef xmlSchemaNotation *xmlSchemaNotationPtr;
241struct _xmlSchemaNotation {
242 xmlSchemaTypeType type; /* The kind of type */
243 xmlChar *name;
244 xmlSchemaAnnotPtr annot;
245 xmlChar *identifier;
246};
247
248/**
249 * A Schemas definition
250 */
251#define XML_SCHEMAS_QUALIF_ELEM 1 << 0
252#define XML_SCHEMAS_QUALIF_ATTR 1 << 1
253struct _xmlSchema {
254 xmlChar *name; /* schema name */
255 xmlChar *targetNamespace; /* the target namespace */
256 xmlChar *version;
257 xmlChar *id;
258 xmlDocPtr doc;
259 xmlSchemaAnnotPtr annot;
260 int flags;
261
262 xmlHashTablePtr typeDecl;
263 xmlHashTablePtr attrDecl;
264 xmlHashTablePtr attrgrpDecl;
265 xmlHashTablePtr elemDecl;
266 xmlHashTablePtr notaDecl;
Daniel Veillard10b6da42002-05-18 07:55:20 +0000267
268 xmlHashTablePtr schemasImports;
Daniel Veillard5f7f9912002-06-17 17:03:00 +0000269
270 void *_private; /* unused by the library for users or bindings */
Daniel Veillard4255d502002-04-16 15:50:10 +0000271};
272
273void xmlSchemaFreeType (xmlSchemaTypePtr type);
274
275#ifdef __cplusplus
276}
277#endif
278
279#endif /* LIBXML_SCHEMAS_ENABLED */
280#endif /* __XML_SCHEMA_INTERNALS_H__ */
281
282