Initial revision
[TestXSLT.git] / libxml2 / include / libxml / schemasInternals.h
1 /*
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 #include <libxml/xmlversion.h>
15
16 #ifdef LIBXML_SCHEMAS_ENABLED
17
18 #include <libxml/xmlregexp.h>
19 #include <libxml/hash.h>
20
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24
25
26 /*
27  * XML Schemas defines multiple type of types.
28  */
29 typedef enum {
30     XML_SCHEMA_TYPE_BASIC = 1,
31     XML_SCHEMA_TYPE_ANY,
32     XML_SCHEMA_TYPE_FACET,
33     XML_SCHEMA_TYPE_SIMPLE,
34     XML_SCHEMA_TYPE_COMPLEX,
35     XML_SCHEMA_TYPE_SEQUENCE,
36     XML_SCHEMA_TYPE_CHOICE,
37     XML_SCHEMA_TYPE_ALL,
38     XML_SCHEMA_TYPE_SIMPLE_CONTENT,
39     XML_SCHEMA_TYPE_COMPLEX_CONTENT,
40     XML_SCHEMA_TYPE_UR,
41     XML_SCHEMA_TYPE_RESTRICTION,
42     XML_SCHEMA_TYPE_EXTENSION,
43     XML_SCHEMA_TYPE_ELEMENT,
44     XML_SCHEMA_TYPE_ATTRIBUTE,
45     XML_SCHEMA_TYPE_ATTRIBUTEGROUP,
46     XML_SCHEMA_TYPE_GROUP,
47     XML_SCHEMA_TYPE_NOTATION,
48     XML_SCHEMA_TYPE_LIST,
49     XML_SCHEMA_TYPE_UNION,
50     XML_SCHEMA_FACET_MININCLUSIVE = 1000,
51     XML_SCHEMA_FACET_MINEXCLUSIVE,
52     XML_SCHEMA_FACET_MAXINCLUSIVE,
53     XML_SCHEMA_FACET_MAXEXCLUSIVE,
54     XML_SCHEMA_FACET_TOTALDIGITS,
55     XML_SCHEMA_FACET_FRACTIONDIGITS,
56     XML_SCHEMA_FACET_PATTERN,
57     XML_SCHEMA_FACET_ENUMERATION,
58     XML_SCHEMA_FACET_WHITESPACE,
59     XML_SCHEMA_FACET_LENGTH,
60     XML_SCHEMA_FACET_MAXLENGTH,
61     XML_SCHEMA_FACET_MINLENGTH
62 } xmlSchemaTypeType;
63
64 typedef enum {
65     XML_SCHEMA_CONTENT_UNKNOWN = 0,
66     XML_SCHEMA_CONTENT_EMPTY = 1,
67     XML_SCHEMA_CONTENT_ELEMENTS,
68     XML_SCHEMA_CONTENT_MIXED,
69     XML_SCHEMA_CONTENT_SIMPLE,
70     XML_SCHEMA_CONTENT_MIXED_OR_ELEMENTS,
71     XML_SCHEMA_CONTENT_BASIC,
72     XML_SCHEMA_CONTENT_ANY
73 } xmlSchemaContentType;
74
75 typedef struct _xmlSchemaVal xmlSchemaVal;
76 typedef xmlSchemaVal *xmlSchemaValPtr;
77
78 typedef struct _xmlSchemaType xmlSchemaType;
79 typedef xmlSchemaType *xmlSchemaTypePtr;
80
81 typedef struct _xmlSchemaFacet xmlSchemaFacet;
82 typedef xmlSchemaFacet *xmlSchemaFacetPtr;
83
84 /**
85  * Annotation
86  */
87 typedef struct _xmlSchemaAnnot xmlSchemaAnnot;
88 typedef xmlSchemaAnnot *xmlSchemaAnnotPtr;
89 struct _xmlSchemaAnnot {
90     struct _xmlSchemaAnnot *next;
91     xmlNodePtr content;         /* the annotation */
92 };
93
94 /**
95  * An attribute definition.
96  */
97
98 #define XML_SCHEMAS_ANYATTR_SKIP        1
99 #define XML_SCHEMAS_ANYATTR_LAX         2
100 #define XML_SCHEMAS_ANYATTR_STRICT      3
101
102 typedef struct _xmlSchemaAttribute xmlSchemaAttribute;
103 typedef xmlSchemaAttribute *xmlSchemaAttributePtr;
104 struct _xmlSchemaAttribute {
105     xmlSchemaTypeType type;     /* The kind of type */
106     struct _xmlSchemaAttribute *next;/* the next attribute if in a group ... */
107     xmlChar *name;
108     xmlChar *id;
109     xmlChar *ref;
110     xmlChar *refNs;
111     xmlChar *typeName;
112     xmlChar *typeNs;
113     xmlSchemaAnnotPtr annot;
114
115     xmlSchemaTypePtr base;
116     int occurs;
117     xmlChar *defValue;
118     xmlSchemaTypePtr subtypes;
119 };
120
121 /**
122  * An attribute group definition.
123  *
124  * xmlSchemaAttribute and xmlSchemaAttributeGroup start of structures
125  * must be kept similar
126  */
127 typedef struct _xmlSchemaAttributeGroup xmlSchemaAttributeGroup;
128 typedef xmlSchemaAttributeGroup *xmlSchemaAttributeGroupPtr;
129 struct _xmlSchemaAttributeGroup {
130     xmlSchemaTypeType type;     /* The kind of type */
131     struct _xmlSchemaAttribute *next;/* the next attribute if in a group ... */
132     xmlChar *name;
133     xmlChar *id;
134     xmlChar *ref;
135     xmlChar *refNs;
136     xmlSchemaAnnotPtr annot;
137
138     xmlSchemaAttributePtr attributes;
139 };
140
141
142 /**
143  * XML_SCHEMAS_TYPE_MIXED:
144  *
145  * the element content type is mixed
146  */
147 #define XML_SCHEMAS_TYPE_MIXED          1 << 0
148
149 /**
150  * _xmlSchemaType:
151  *
152  * Schemas type definition.
153  */
154 struct _xmlSchemaType {
155     xmlSchemaTypeType type;     /* The kind of type */
156     struct _xmlSchemaType *next;/* the next type if in a sequence ... */
157     xmlChar *name;
158     xmlChar *id;
159     xmlChar *ref;
160     xmlChar *refNs;
161     xmlSchemaAnnotPtr annot;
162     xmlSchemaTypePtr subtypes;
163     xmlSchemaAttributePtr attributes;
164     xmlNodePtr node;
165     int minOccurs;
166     int maxOccurs;
167
168     int flags;
169     xmlSchemaContentType contentType;
170     xmlChar *base;
171     xmlChar *baseNs;
172     xmlSchemaTypePtr baseType;
173     xmlSchemaFacetPtr facets;
174 };
175
176 /**
177  * xmlSchemaElement:
178  * An element definition.
179  *
180  * xmlSchemaType, xmlSchemaFacet and xmlSchemaElement start of
181  * structures must be kept similar
182  */
183 /**
184  * XML_SCHEMAS_ELEM_NILLABLE:
185  *
186  * the element is nillable
187  */
188 #define XML_SCHEMAS_ELEM_NILLABLE       1 << 0
189 /**
190  * XML_SCHEMAS_ELEM_GLOBAL:
191  *
192  * the element is global
193  */
194 #define XML_SCHEMAS_ELEM_GLOBAL         1 << 1
195 /**
196  * XML_SCHEMAS_ELEM_DEFAULT:
197  *
198  * the element has a default value
199  */
200 #define XML_SCHEMAS_ELEM_DEFAULT        1 << 2
201 /**
202  * XML_SCHEMAS_ELEM_FIXED:
203  *
204  * the element has a fixed value
205  */
206 #define XML_SCHEMAS_ELEM_FIXED          1 << 3
207 /**
208  * XML_SCHEMAS_ELEM_ABSTRACT:
209  *
210  * the element is abstract
211  */
212 #define XML_SCHEMAS_ELEM_ABSTRACT       1 << 4
213 /**
214  * XML_SCHEMAS_ELEM_TOPLEVEL:
215  *
216  * the element is top level
217  */
218 #define XML_SCHEMAS_ELEM_TOPLEVEL       1 << 5
219 /**
220  * XML_SCHEMAS_ELEM_REF:
221  *
222  * the element is a reference to a type
223  */
224 #define XML_SCHEMAS_ELEM_REF            1 << 6
225
226 typedef struct _xmlSchemaElement xmlSchemaElement;
227 typedef xmlSchemaElement *xmlSchemaElementPtr;
228 struct _xmlSchemaElement {
229     xmlSchemaTypeType type;     /* The kind of type */
230     struct _xmlSchemaType *next;/* the next type if in a sequence ... */
231     xmlChar *name;
232     xmlChar *id;
233     xmlChar *ref;
234     xmlChar *refNs;
235     xmlSchemaAnnotPtr annot;
236     xmlSchemaTypePtr subtypes;
237     xmlSchemaAttributePtr attributes;
238     xmlNodePtr node;
239     int minOccurs;
240     int maxOccurs;
241
242     int flags;
243     xmlChar *targetNamespace;
244     xmlChar *namedType;
245     xmlChar *namedTypeNs;
246     xmlChar *substGroup;
247     xmlChar *substGroupNs;
248     xmlChar *scope;
249     xmlChar *value;
250     struct _xmlSchemaElement *refDecl;
251     xmlRegexpPtr contModel;
252     xmlSchemaContentType contentType;
253 };
254
255 /*
256  * XML_SCHEMAS_FACET_UNKNOWN:
257  *
258  * unknown facet handling
259  */
260 #define XML_SCHEMAS_FACET_UNKNOWN       0
261 /*
262  * XML_SCHEMAS_FACET_PRESERVE:
263  *
264  * preserve the type of the facet
265  */
266 #define XML_SCHEMAS_FACET_PRESERVE      1
267 /*
268  * XML_SCHEMAS_FACET_REPLACE:
269  *
270  * replace the type of the facet
271  */
272 #define XML_SCHEMAS_FACET_REPLACE       2
273 /*
274  * XML_SCHEMAS_FACET_COLLAPSE:
275  *
276  * collapse the types of the facet
277  */
278 #define XML_SCHEMAS_FACET_COLLAPSE      3
279
280 /**
281  * A facet definition.
282  */
283 struct _xmlSchemaFacet {
284     xmlSchemaTypeType type;     /* The kind of type */
285     struct _xmlSchemaFacet *next;/* the next type if in a sequence ... */
286     xmlChar *value;
287     xmlChar *id;
288     xmlSchemaAnnotPtr annot;
289     xmlNodePtr node;
290     int fixed;
291     int whitespace;
292     xmlSchemaValPtr val;
293     xmlRegexpPtr    regexp;
294 };
295
296 /**
297  * A notation definition.
298  */
299 typedef struct _xmlSchemaNotation xmlSchemaNotation;
300 typedef xmlSchemaNotation *xmlSchemaNotationPtr;
301 struct _xmlSchemaNotation {
302     xmlSchemaTypeType type;     /* The kind of type */
303     xmlChar *name;
304     xmlSchemaAnnotPtr annot;
305     xmlChar *identifier;
306 };
307
308 /**
309  * XML_SCHEMAS_QUALIF_ELEM:
310  *
311  * the shemas requires qualified elements
312  */
313 #define XML_SCHEMAS_QUALIF_ELEM         1 << 0
314 /**
315  * XML_SCHEMAS_QUALIF_ATTR:
316  *
317  * the shemas requires qualified attributes
318  */
319 #define XML_SCHEMAS_QUALIF_ATTR         1 << 1
320 /**
321  * _xmlSchema:
322  *
323  * A Schemas definition
324  */
325 struct _xmlSchema {
326     xmlChar *name;        /* schema name */
327     xmlChar *targetNamespace;     /* the target namespace */
328     xmlChar *version;
329     xmlChar *id;
330     xmlDocPtr doc;
331     xmlSchemaAnnotPtr annot;
332     int flags;
333
334     xmlHashTablePtr typeDecl;
335     xmlHashTablePtr attrDecl;
336     xmlHashTablePtr attrgrpDecl;
337     xmlHashTablePtr elemDecl;
338     xmlHashTablePtr notaDecl;
339
340     xmlHashTablePtr schemasImports;
341
342     void *_private;     /* unused by the library for users or bindings */
343 };
344
345 void    xmlSchemaFreeType       (xmlSchemaTypePtr type);
346
347 #ifdef __cplusplus
348 }
349 #endif
350
351 #endif /* LIBXML_SCHEMAS_ENABLED */
352 #endif /* __XML_SCHEMA_INTERNALS_H__ */
353
354