blob: e59e15767ca171c2404933e5912b577d91407e1b [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,
47 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;
120};
121
122/**
123 * An attribute group definition.
124 *
125 * xmlSchemaAttribute and xmlSchemaAttributeGroup start of structures
126 * must be kept similar
127 */
128typedef struct _xmlSchemaAttributeGroup xmlSchemaAttributeGroup;
129typedef xmlSchemaAttributeGroup *xmlSchemaAttributeGroupPtr;
130struct _xmlSchemaAttributeGroup {
131 xmlSchemaTypeType type; /* The kind of type */
132 struct _xmlSchemaAttribute *next;/* the next attribute if in a group ... */
133 xmlChar *name;
134 xmlChar *id;
135 xmlChar *ref;
136 xmlChar *refNs;
137 xmlSchemaAnnotPtr annot;
138
139 xmlSchemaAttributePtr attributes;
140};
141
142
143/**
144 * Schemas type definition.
145 */
146#define XML_SCHEMAS_TYPE_MIXED 1 << 0
147
148struct _xmlSchemaType {
149 xmlSchemaTypeType type; /* The kind of type */
150 struct _xmlSchemaType *next;/* the next type if in a sequence ... */
151 xmlChar *name;
152 xmlChar *id;
153 xmlChar *ref;
154 xmlChar *refNs;
155 xmlSchemaAnnotPtr annot;
156 xmlSchemaTypePtr subtypes;
157 xmlSchemaAttributePtr attributes;
158 xmlNodePtr node;
159 int minOccurs;
160 int maxOccurs;
161
162 int flags;
163 xmlSchemaContentType contentType;
164 xmlChar *base;
165 xmlChar *baseNs;
166 xmlSchemaTypePtr baseType;
167 xmlSchemaFacetPtr facets;
168};
169
170/**
171 * An element definition.
172 *
173 * xmlSchemaType, xmlSchemaFacet and xmlSchemaElement start of
174 * structures must be kept similar
175 */
176#define XML_SCHEMAS_ELEM_NILLABLE 1 << 0
177#define XML_SCHEMAS_ELEM_GLOBAL 1 << 1
178#define XML_SCHEMAS_ELEM_DEFAULT 1 << 2
179#define XML_SCHEMAS_ELEM_FIXED 1 << 3
180#define XML_SCHEMAS_ELEM_ABSTRACT 1 << 4
181#define XML_SCHEMAS_ELEM_TOPLEVEL 1 << 5
182#define XML_SCHEMAS_ELEM_REF 1 << 6
183
184typedef struct _xmlSchemaElement xmlSchemaElement;
185typedef xmlSchemaElement *xmlSchemaElementPtr;
186struct _xmlSchemaElement {
187 xmlSchemaTypeType type; /* The kind of type */
188 struct _xmlSchemaType *next;/* the next type if in a sequence ... */
189 xmlChar *name;
190 xmlChar *id;
191 xmlChar *ref;
192 xmlChar *refNs;
193 xmlSchemaAnnotPtr annot;
194 xmlSchemaTypePtr subtypes;
195 xmlSchemaAttributePtr attributes;
196 xmlNodePtr node;
197 int minOccurs;
198 int maxOccurs;
199
200 int flags;
201 xmlChar *targetNamespace;
202 xmlChar *namedType;
203 xmlChar *namedTypeNs;
204 xmlChar *substGroup;
205 xmlChar *substGroupNs;
206 xmlChar *scope;
207 xmlChar *value;
208 struct _xmlSchemaElement *refDecl;
209 xmlRegexpPtr contModel;
Daniel Veillard88c58912002-04-23 07:12:20 +0000210 xmlSchemaContentType contentType;
Daniel Veillard4255d502002-04-16 15:50:10 +0000211};
212
213/**
214 * An facet definition.
215 *
216 */
217#define XML_SCHEMAS_FACET_UNKNOWN 0
218#define XML_SCHEMAS_FACET_PRESERVE 1
219#define XML_SCHEMAS_FACET_REPLACE 2
220#define XML_SCHEMAS_FACET_COLLAPSE 3
221
222struct _xmlSchemaFacet {
223 xmlSchemaTypeType type; /* The kind of type */
224 struct _xmlSchemaFacet *next;/* the next type if in a sequence ... */
225 xmlChar *value;
226 xmlChar *id;
227 xmlSchemaAnnotPtr annot;
228 xmlNodePtr node;
229 int fixed;
230 int whitespace;
231 xmlSchemaValPtr val;
232 xmlRegexpPtr regexp;
233};
234
235/**
236 * A notation definition.
237 */
238typedef struct _xmlSchemaNotation xmlSchemaNotation;
239typedef xmlSchemaNotation *xmlSchemaNotationPtr;
240struct _xmlSchemaNotation {
241 xmlSchemaTypeType type; /* The kind of type */
242 xmlChar *name;
243 xmlSchemaAnnotPtr annot;
244 xmlChar *identifier;
245};
246
247/**
248 * A Schemas definition
249 */
250#define XML_SCHEMAS_QUALIF_ELEM 1 << 0
251#define XML_SCHEMAS_QUALIF_ATTR 1 << 1
252struct _xmlSchema {
253 xmlChar *name; /* schema name */
254 xmlChar *targetNamespace; /* the target namespace */
255 xmlChar *version;
256 xmlChar *id;
257 xmlDocPtr doc;
258 xmlSchemaAnnotPtr annot;
259 int flags;
260
261 xmlHashTablePtr typeDecl;
262 xmlHashTablePtr attrDecl;
263 xmlHashTablePtr attrgrpDecl;
264 xmlHashTablePtr elemDecl;
265 xmlHashTablePtr notaDecl;
266};
267
268void xmlSchemaFreeType (xmlSchemaTypePtr type);
269
270#ifdef __cplusplus
271}
272#endif
273
274#endif /* LIBXML_SCHEMAS_ENABLED */
275#endif /* __XML_SCHEMA_INTERNALS_H__ */
276
277