blob: a044b672c14409f68a4cad68494fe0cf6fbea329 [file] [log] [blame]
Daniel Veillard4255d502002-04-16 15:50:10 +00001/*
Daniel Veillardbe586972003-11-18 20:56:51 +00002 * Summary: internal interfaces for XML Schemas
3 * Description: internal interfaces for the XML Schemas handling
4 * and schema validity checking
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_INTERNALS_H__
13#define __XML_SCHEMA_INTERNALS_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/xmlregexp.h>
Daniel Veillard8326e732003-01-07 00:19:07 +000020#include <libxml/hash.h>
Daniel Veillard4255d502002-04-16 15:50:10 +000021
22#ifdef __cplusplus
23extern "C" {
24#endif
25
26
27/*
28 * XML Schemas defines multiple type of types.
29 */
30typedef enum {
31 XML_SCHEMA_TYPE_BASIC = 1,
32 XML_SCHEMA_TYPE_ANY,
33 XML_SCHEMA_TYPE_FACET,
34 XML_SCHEMA_TYPE_SIMPLE,
35 XML_SCHEMA_TYPE_COMPLEX,
36 XML_SCHEMA_TYPE_SEQUENCE,
37 XML_SCHEMA_TYPE_CHOICE,
38 XML_SCHEMA_TYPE_ALL,
39 XML_SCHEMA_TYPE_SIMPLE_CONTENT,
40 XML_SCHEMA_TYPE_COMPLEX_CONTENT,
41 XML_SCHEMA_TYPE_UR,
42 XML_SCHEMA_TYPE_RESTRICTION,
43 XML_SCHEMA_TYPE_EXTENSION,
44 XML_SCHEMA_TYPE_ELEMENT,
45 XML_SCHEMA_TYPE_ATTRIBUTE,
Daniel Veillard13e04c62002-04-23 17:51:29 +000046 XML_SCHEMA_TYPE_ATTRIBUTEGROUP,
Daniel Veillard4255d502002-04-16 15:50:10 +000047 XML_SCHEMA_TYPE_GROUP,
48 XML_SCHEMA_TYPE_NOTATION,
49 XML_SCHEMA_TYPE_LIST,
50 XML_SCHEMA_TYPE_UNION,
51 XML_SCHEMA_FACET_MININCLUSIVE = 1000,
52 XML_SCHEMA_FACET_MINEXCLUSIVE,
53 XML_SCHEMA_FACET_MAXINCLUSIVE,
54 XML_SCHEMA_FACET_MAXEXCLUSIVE,
55 XML_SCHEMA_FACET_TOTALDIGITS,
56 XML_SCHEMA_FACET_FRACTIONDIGITS,
57 XML_SCHEMA_FACET_PATTERN,
58 XML_SCHEMA_FACET_ENUMERATION,
59 XML_SCHEMA_FACET_WHITESPACE,
60 XML_SCHEMA_FACET_LENGTH,
61 XML_SCHEMA_FACET_MAXLENGTH,
62 XML_SCHEMA_FACET_MINLENGTH
63} xmlSchemaTypeType;
64
65typedef enum {
66 XML_SCHEMA_CONTENT_UNKNOWN = 0,
67 XML_SCHEMA_CONTENT_EMPTY = 1,
68 XML_SCHEMA_CONTENT_ELEMENTS,
69 XML_SCHEMA_CONTENT_MIXED,
70 XML_SCHEMA_CONTENT_SIMPLE,
71 XML_SCHEMA_CONTENT_MIXED_OR_ELEMENTS,
Daniel Veillard88c58912002-04-23 07:12:20 +000072 XML_SCHEMA_CONTENT_BASIC,
73 XML_SCHEMA_CONTENT_ANY
Daniel Veillard4255d502002-04-16 15:50:10 +000074} xmlSchemaContentType;
75
76typedef struct _xmlSchemaVal xmlSchemaVal;
77typedef xmlSchemaVal *xmlSchemaValPtr;
78
79typedef struct _xmlSchemaType xmlSchemaType;
80typedef xmlSchemaType *xmlSchemaTypePtr;
81
82typedef struct _xmlSchemaFacet xmlSchemaFacet;
83typedef xmlSchemaFacet *xmlSchemaFacetPtr;
84
85/**
86 * Annotation
87 */
88typedef struct _xmlSchemaAnnot xmlSchemaAnnot;
89typedef xmlSchemaAnnot *xmlSchemaAnnotPtr;
90struct _xmlSchemaAnnot {
91 struct _xmlSchemaAnnot *next;
92 xmlNodePtr content; /* the annotation */
93};
94
95/**
96 * An attribute definition.
97 */
98
99#define XML_SCHEMAS_ANYATTR_SKIP 1
100#define XML_SCHEMAS_ANYATTR_LAX 2
101#define XML_SCHEMAS_ANYATTR_STRICT 3
102
103typedef struct _xmlSchemaAttribute xmlSchemaAttribute;
104typedef xmlSchemaAttribute *xmlSchemaAttributePtr;
105struct _xmlSchemaAttribute {
106 xmlSchemaTypeType type; /* The kind of type */
107 struct _xmlSchemaAttribute *next;/* the next attribute if in a group ... */
108 xmlChar *name;
109 xmlChar *id;
110 xmlChar *ref;
111 xmlChar *refNs;
112 xmlChar *typeName;
113 xmlChar *typeNs;
114 xmlSchemaAnnotPtr annot;
115
116 xmlSchemaTypePtr base;
117 int occurs;
118 xmlChar *defValue;
119 xmlSchemaTypePtr subtypes;
Daniel Veillard75bb3bb2003-05-12 15:25:56 +0000120 xmlNodePtr node;
Daniel Veillard4255d502002-04-16 15:50:10 +0000121};
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;
Daniel Veillard75bb3bb2003-05-12 15:25:56 +0000141 xmlNodePtr node;
Daniel Veillard4255d502002-04-16 15:50:10 +0000142};
143
144
145/**
Daniel Veillarda9b66d02002-12-11 14:23:49 +0000146 * XML_SCHEMAS_TYPE_MIXED:
147 *
148 * the element content type is mixed
Daniel Veillard4255d502002-04-16 15:50:10 +0000149 */
150#define XML_SCHEMAS_TYPE_MIXED 1 << 0
151
Daniel Veillarda9b66d02002-12-11 14:23:49 +0000152/**
153 * _xmlSchemaType:
154 *
155 * Schemas type definition.
156 */
Daniel Veillard4255d502002-04-16 15:50:10 +0000157struct _xmlSchemaType {
158 xmlSchemaTypeType type; /* The kind of type */
159 struct _xmlSchemaType *next;/* the next type if in a sequence ... */
160 xmlChar *name;
161 xmlChar *id;
162 xmlChar *ref;
163 xmlChar *refNs;
164 xmlSchemaAnnotPtr annot;
165 xmlSchemaTypePtr subtypes;
166 xmlSchemaAttributePtr attributes;
167 xmlNodePtr node;
168 int minOccurs;
169 int maxOccurs;
170
171 int flags;
172 xmlSchemaContentType contentType;
173 xmlChar *base;
174 xmlChar *baseNs;
175 xmlSchemaTypePtr baseType;
176 xmlSchemaFacetPtr facets;
177};
178
William M. Brack60f394e2003-11-16 06:25:42 +0000179/*
Daniel Veillarda9b66d02002-12-11 14:23:49 +0000180 * xmlSchemaElement:
Daniel Veillard4255d502002-04-16 15:50:10 +0000181 * An element definition.
182 *
183 * xmlSchemaType, xmlSchemaFacet and xmlSchemaElement start of
184 * structures must be kept similar
185 */
Daniel Veillarda9b66d02002-12-11 14:23:49 +0000186/**
187 * XML_SCHEMAS_ELEM_NILLABLE:
188 *
189 * the element is nillable
190 */
Daniel Veillard4255d502002-04-16 15:50:10 +0000191#define XML_SCHEMAS_ELEM_NILLABLE 1 << 0
Daniel Veillarda9b66d02002-12-11 14:23:49 +0000192/**
193 * XML_SCHEMAS_ELEM_GLOBAL:
194 *
195 * the element is global
196 */
Daniel Veillard4255d502002-04-16 15:50:10 +0000197#define XML_SCHEMAS_ELEM_GLOBAL 1 << 1
Daniel Veillarda9b66d02002-12-11 14:23:49 +0000198/**
199 * XML_SCHEMAS_ELEM_DEFAULT:
200 *
201 * the element has a default value
202 */
Daniel Veillard4255d502002-04-16 15:50:10 +0000203#define XML_SCHEMAS_ELEM_DEFAULT 1 << 2
Daniel Veillarda9b66d02002-12-11 14:23:49 +0000204/**
205 * XML_SCHEMAS_ELEM_FIXED:
206 *
207 * the element has a fixed value
208 */
Daniel Veillard4255d502002-04-16 15:50:10 +0000209#define XML_SCHEMAS_ELEM_FIXED 1 << 3
Daniel Veillarda9b66d02002-12-11 14:23:49 +0000210/**
211 * XML_SCHEMAS_ELEM_ABSTRACT:
212 *
213 * the element is abstract
214 */
Daniel Veillard4255d502002-04-16 15:50:10 +0000215#define XML_SCHEMAS_ELEM_ABSTRACT 1 << 4
Daniel Veillarda9b66d02002-12-11 14:23:49 +0000216/**
217 * XML_SCHEMAS_ELEM_TOPLEVEL:
218 *
219 * the element is top level
220 */
Daniel Veillard4255d502002-04-16 15:50:10 +0000221#define XML_SCHEMAS_ELEM_TOPLEVEL 1 << 5
Daniel Veillarda9b66d02002-12-11 14:23:49 +0000222/**
223 * XML_SCHEMAS_ELEM_REF:
224 *
225 * the element is a reference to a type
226 */
Daniel Veillard4255d502002-04-16 15:50:10 +0000227#define XML_SCHEMAS_ELEM_REF 1 << 6
228
229typedef struct _xmlSchemaElement xmlSchemaElement;
230typedef xmlSchemaElement *xmlSchemaElementPtr;
231struct _xmlSchemaElement {
232 xmlSchemaTypeType type; /* The kind of type */
233 struct _xmlSchemaType *next;/* the next type if in a sequence ... */
234 xmlChar *name;
235 xmlChar *id;
236 xmlChar *ref;
237 xmlChar *refNs;
238 xmlSchemaAnnotPtr annot;
239 xmlSchemaTypePtr subtypes;
240 xmlSchemaAttributePtr attributes;
241 xmlNodePtr node;
242 int minOccurs;
243 int maxOccurs;
244
245 int flags;
246 xmlChar *targetNamespace;
247 xmlChar *namedType;
248 xmlChar *namedTypeNs;
249 xmlChar *substGroup;
250 xmlChar *substGroupNs;
251 xmlChar *scope;
252 xmlChar *value;
253 struct _xmlSchemaElement *refDecl;
254 xmlRegexpPtr contModel;
Daniel Veillard88c58912002-04-23 07:12:20 +0000255 xmlSchemaContentType contentType;
Daniel Veillard4255d502002-04-16 15:50:10 +0000256};
257
Daniel Veillarda9b66d02002-12-11 14:23:49 +0000258/*
259 * XML_SCHEMAS_FACET_UNKNOWN:
Daniel Veillard4255d502002-04-16 15:50:10 +0000260 *
Daniel Veillarda9b66d02002-12-11 14:23:49 +0000261 * unknown facet handling
Daniel Veillard4255d502002-04-16 15:50:10 +0000262 */
263#define XML_SCHEMAS_FACET_UNKNOWN 0
Daniel Veillarda9b66d02002-12-11 14:23:49 +0000264/*
265 * XML_SCHEMAS_FACET_PRESERVE:
266 *
267 * preserve the type of the facet
268 */
Daniel Veillard4255d502002-04-16 15:50:10 +0000269#define XML_SCHEMAS_FACET_PRESERVE 1
Daniel Veillarda9b66d02002-12-11 14:23:49 +0000270/*
271 * XML_SCHEMAS_FACET_REPLACE:
272 *
273 * replace the type of the facet
274 */
Daniel Veillard4255d502002-04-16 15:50:10 +0000275#define XML_SCHEMAS_FACET_REPLACE 2
Daniel Veillarda9b66d02002-12-11 14:23:49 +0000276/*
277 * XML_SCHEMAS_FACET_COLLAPSE:
278 *
279 * collapse the types of the facet
280 */
Daniel Veillard4255d502002-04-16 15:50:10 +0000281#define XML_SCHEMAS_FACET_COLLAPSE 3
282
Daniel Veillarda9b66d02002-12-11 14:23:49 +0000283/**
284 * A facet definition.
285 */
Daniel Veillard4255d502002-04-16 15:50:10 +0000286struct _xmlSchemaFacet {
287 xmlSchemaTypeType type; /* The kind of type */
288 struct _xmlSchemaFacet *next;/* the next type if in a sequence ... */
289 xmlChar *value;
290 xmlChar *id;
291 xmlSchemaAnnotPtr annot;
292 xmlNodePtr node;
293 int fixed;
294 int whitespace;
295 xmlSchemaValPtr val;
296 xmlRegexpPtr regexp;
297};
298
299/**
300 * A notation definition.
301 */
302typedef struct _xmlSchemaNotation xmlSchemaNotation;
303typedef xmlSchemaNotation *xmlSchemaNotationPtr;
304struct _xmlSchemaNotation {
305 xmlSchemaTypeType type; /* The kind of type */
306 xmlChar *name;
307 xmlSchemaAnnotPtr annot;
308 xmlChar *identifier;
309};
310
311/**
Daniel Veillarda9b66d02002-12-11 14:23:49 +0000312 * XML_SCHEMAS_QUALIF_ELEM:
313 *
314 * the shemas requires qualified elements
Daniel Veillard4255d502002-04-16 15:50:10 +0000315 */
316#define XML_SCHEMAS_QUALIF_ELEM 1 << 0
Daniel Veillarda9b66d02002-12-11 14:23:49 +0000317/**
318 * XML_SCHEMAS_QUALIF_ATTR:
319 *
320 * the shemas requires qualified attributes
321 */
Daniel Veillard4255d502002-04-16 15:50:10 +0000322#define XML_SCHEMAS_QUALIF_ATTR 1 << 1
Daniel Veillarda9b66d02002-12-11 14:23:49 +0000323/**
324 * _xmlSchema:
325 *
326 * A Schemas definition
327 */
Daniel Veillard4255d502002-04-16 15:50:10 +0000328struct _xmlSchema {
329 xmlChar *name; /* schema name */
330 xmlChar *targetNamespace; /* the target namespace */
331 xmlChar *version;
332 xmlChar *id;
333 xmlDocPtr doc;
334 xmlSchemaAnnotPtr annot;
335 int flags;
336
337 xmlHashTablePtr typeDecl;
338 xmlHashTablePtr attrDecl;
339 xmlHashTablePtr attrgrpDecl;
340 xmlHashTablePtr elemDecl;
341 xmlHashTablePtr notaDecl;
Daniel Veillard10b6da42002-05-18 07:55:20 +0000342
343 xmlHashTablePtr schemasImports;
Daniel Veillard5f7f9912002-06-17 17:03:00 +0000344
345 void *_private; /* unused by the library for users or bindings */
Daniel Veillarda84c0b32003-06-02 16:58:46 +0000346 xmlHashTablePtr groupDecl;
Daniel Veillard4255d502002-04-16 15:50:10 +0000347};
348
Igor Zlatkovic76874e42003-08-25 09:05:12 +0000349XMLPUBFUN void XMLCALL xmlSchemaFreeType (xmlSchemaTypePtr type);
Daniel Veillard4255d502002-04-16 15:50:10 +0000350
351#ifdef __cplusplus
352}
353#endif
354
355#endif /* LIBXML_SCHEMAS_ENABLED */
356#endif /* __XML_SCHEMA_INTERNALS_H__ */
357
358