2 * Summary: internal interfaces for XML Schemas
3 * Description: internal interfaces for the XML Schemas handling
4 * and schema validity checking
6 * Copy: See Copyright for the status of this software.
8 * Author: Daniel Veillard
9 * Portion Copyright © 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
18 #ifndef XML_SCHEMA_INTERNALS_H
19 #define XML_SCHEMA_INTERNALS_H
21 #include <stdapis/libxml2/libxml2_xmlversion.h>
23 #if defined(LIBXML_SCHEMAS_ENABLED) || defined(XMLENGINE_XMLSCHEMA_DATATYPES)
25 #ifdef LIBXML_REGEXP_ENABLED
26 #include "libxml2_xmlregexp.h"
29 #include <stdapis/libxml2/libxml2_hash.h>
30 #include <stdapis/libxml2/libxml2_dict.h>
37 #define XML_SCHEMAS_NAMESPACE_NAME \
38 (const xmlChar*) "http://www.w3.org/2001/XMLSchema"
42 * XML Schemas defines multiple type of types.
45 XML_SCHEMA_TYPE_BASIC = 1,
47 XML_SCHEMA_TYPE_FACET,
48 XML_SCHEMA_TYPE_SIMPLE,
49 XML_SCHEMA_TYPE_COMPLEX,
50 XML_SCHEMA_TYPE_SEQUENCE,
51 XML_SCHEMA_TYPE_CHOICE,
53 XML_SCHEMA_TYPE_SIMPLE_CONTENT,
54 XML_SCHEMA_TYPE_COMPLEX_CONTENT,
56 XML_SCHEMA_TYPE_RESTRICTION,
57 XML_SCHEMA_TYPE_EXTENSION,
58 XML_SCHEMA_TYPE_ELEMENT,
59 XML_SCHEMA_TYPE_ATTRIBUTE,
60 XML_SCHEMA_TYPE_ATTRIBUTEGROUP,
61 XML_SCHEMA_TYPE_GROUP,
62 XML_SCHEMA_TYPE_NOTATION,
64 XML_SCHEMA_TYPE_UNION,
65 XML_SCHEMA_TYPE_ANY_ATTRIBUTE,
66 XML_SCHEMA_FACET_MININCLUSIVE = 1000,
67 XML_SCHEMA_FACET_MINEXCLUSIVE,
68 XML_SCHEMA_FACET_MAXINCLUSIVE,
69 XML_SCHEMA_FACET_MAXEXCLUSIVE,
70 XML_SCHEMA_FACET_TOTALDIGITS,
71 XML_SCHEMA_FACET_FRACTIONDIGITS,
72 XML_SCHEMA_FACET_PATTERN,
73 XML_SCHEMA_FACET_ENUMERATION,
74 XML_SCHEMA_FACET_WHITESPACE,
75 XML_SCHEMA_FACET_LENGTH,
76 XML_SCHEMA_FACET_MAXLENGTH,
77 XML_SCHEMA_FACET_MINLENGTH
81 XML_SCHEMA_CONTENT_UNKNOWN = 0,
82 XML_SCHEMA_CONTENT_EMPTY = 1,
83 XML_SCHEMA_CONTENT_ELEMENTS,
84 XML_SCHEMA_CONTENT_MIXED,
85 XML_SCHEMA_CONTENT_SIMPLE,
86 XML_SCHEMA_CONTENT_MIXED_OR_ELEMENTS,
87 XML_SCHEMA_CONTENT_BASIC,
88 XML_SCHEMA_CONTENT_ANY
89 } xmlSchemaContentType;
92 XML_SCHEMAS_UNKNOWN = 0,
94 XML_SCHEMAS_NORMSTRING,
99 XML_SCHEMAS_GMONTHDAY,
101 XML_SCHEMAS_GYEARMONTH,
103 XML_SCHEMAS_DATETIME,
104 XML_SCHEMAS_DURATION,
109 XML_SCHEMAS_LANGUAGE,
111 XML_SCHEMAS_NMTOKENS,
119 XML_SCHEMAS_ENTITIES,
120 XML_SCHEMAS_NOTATION,
123 XML_SCHEMAS_NPINTEGER,
124 XML_SCHEMAS_NINTEGER,
125 XML_SCHEMAS_NNINTEGER,
126 XML_SCHEMAS_PINTEGER,
135 XML_SCHEMAS_HEXBINARY,
136 XML_SCHEMAS_BASE64BINARY
141 struct _xmlSchemaValDate {
143 unsigned int mon :4; /* 1 <= mon <= 12 */
144 unsigned int day :5; /* 1 <= day <= 31 */
145 unsigned int hour:5; /* 0 <= hour <= 23 */
146 unsigned int min :6; /* 0 <= min <= 59 */
148 unsigned int tz_flag :1; /* is tzo explicitely set? */
149 int tzo :11; /* -1440 <= tzo <= 1440 */
153 typedef struct _xmlSchemaValDuration xmlSchemaValDuration;
154 typedef xmlSchemaValDuration *xmlSchemaValDurationPtr;
155 struct _xmlSchemaValDuration {
156 long mon; /* mon stores years also */
158 double sec; /* sec stores min and hour also */
161 typedef struct _xmlSchemaValDecimal xmlSchemaValDecimal;
162 typedef xmlSchemaValDecimal *xmlSchemaValDecimalPtr;
163 struct _xmlSchemaValDecimal {
164 /* would use long long but not portable */
171 unsigned int total:8;
174 typedef struct _xmlSchemaValQName xmlSchemaValQName;
175 typedef xmlSchemaValQName *xmlSchemaValQNamePtr;
176 struct _xmlSchemaValQName {
181 typedef struct _xmlSchemaValHex xmlSchemaValHex;
182 typedef xmlSchemaValHex *xmlSchemaValHexPtr;
183 struct _xmlSchemaValHex {
188 typedef struct _xmlSchemaValBase64 xmlSchemaValBase64;
189 typedef xmlSchemaValBase64 *xmlSchemaValBase64Ptr;
190 struct _xmlSchemaValBase64 {
195 typedef struct _xmlSchemaValDate xmlSchemaValDate;
196 typedef xmlSchemaValDate *xmlSchemaValDatePtr;
198 struct _xmlSchemaVal {
199 xmlSchemaValType type;
201 xmlSchemaValDecimal decimal;
202 xmlSchemaValDate date;
203 xmlSchemaValDuration dur;
204 xmlSchemaValQName qname;
206 xmlSchemaValBase64 base64;
214 typedef struct _xmlSchemaVal xmlSchemaVal;
215 typedef xmlSchemaVal *xmlSchemaValPtr;
217 typedef struct _xmlSchemaType xmlSchemaType;
218 typedef xmlSchemaType *xmlSchemaTypePtr;
220 typedef struct _xmlSchemaFacet xmlSchemaFacet;
221 typedef xmlSchemaFacet *xmlSchemaFacetPtr;
226 typedef struct _xmlSchemaAnnot xmlSchemaAnnot;
227 typedef xmlSchemaAnnot *xmlSchemaAnnotPtr;
228 struct _xmlSchemaAnnot {
229 struct _xmlSchemaAnnot *next;
230 xmlNodePtr content; /* the annotation */
234 * XML_SCHEMAS_ANYATTR_SKIP:
236 * Skip unknown attribute from validation
238 #define XML_SCHEMAS_ANYATTR_SKIP 1
240 * XML_SCHEMAS_ANYATTR_LAX:
242 * Ignore validation non definition on attributes
244 #define XML_SCHEMAS_ANYATTR_LAX 2
246 * XML_SCHEMAS_ANYATTR_STRICT:
248 * Apply strict validation rules on attributes
250 #define XML_SCHEMAS_ANYATTR_STRICT 3
253 * XML_SCHEMAS_ATTR_USE_PROHIBITED:
255 * The attribute is prohibited.
257 #define XML_SCHEMAS_ATTR_USE_PROHIBITED 0
260 * XML_SCHEMAS_ATTR_USE_REQUIRED:
262 * The attribute is required.
264 #define XML_SCHEMAS_ATTR_USE_REQUIRED 1
267 * XML_SCHEMAS_ATTR_USE_OPTIONAL:
269 * The attribute is optional.
271 #define XML_SCHEMAS_ATTR_USE_OPTIONAL 2
274 * XML_SCHEMAS_ATTR_NSDEFAULT:
276 * allow elements in no namespace
278 #define XML_SCHEMAS_ATTR_NSDEFAULT 1 << 7
281 * xmlSchemaAttribute:
282 * An attribute definition.
285 typedef struct _xmlSchemaAttribute xmlSchemaAttribute;
286 typedef xmlSchemaAttribute *xmlSchemaAttributePtr;
287 struct _xmlSchemaAttribute {
288 xmlSchemaTypeType type; /* The kind of type */
289 struct _xmlSchemaAttribute *next;/* the next attribute if in a group ... */
293 const xmlChar *refNs;
294 const xmlChar *typeName;
295 const xmlChar *typeNs;
296 xmlSchemaAnnotPtr annot;
298 xmlSchemaTypePtr base;
300 const xmlChar *defValue;
301 xmlSchemaTypePtr subtypes;
303 const xmlChar *targetNamespace;
308 * An attribute group definition.
310 * xmlSchemaAttribute and xmlSchemaAttributeGroup start of structures
311 * must be kept similar
313 typedef struct _xmlSchemaAttributeGroup xmlSchemaAttributeGroup;
314 typedef xmlSchemaAttributeGroup *xmlSchemaAttributeGroupPtr;
315 struct _xmlSchemaAttributeGroup {
316 xmlSchemaTypeType type; /* The kind of type */
317 struct _xmlSchemaAttribute *next;/* the next attribute if in a group ... */
321 const xmlChar *refNs;
322 xmlSchemaAnnotPtr annot;
324 xmlSchemaAttributePtr attributes;
330 * XML_SCHEMAS_TYPE_MIXED:
332 * the element content type is mixed
334 #define XML_SCHEMAS_TYPE_MIXED 1 << 0
339 * Schemas type definition.
341 struct _xmlSchemaType {
342 xmlSchemaTypeType type; /* The kind of type */
343 struct _xmlSchemaType *next;/* the next type if in a sequence ... */
347 const xmlChar *refNs;
348 xmlSchemaAnnotPtr annot;
349 xmlSchemaTypePtr subtypes;
350 xmlSchemaAttributePtr attributes;
356 xmlSchemaContentType contentType;
358 const xmlChar *baseNs;
359 xmlSchemaTypePtr baseType;
360 xmlSchemaFacetPtr facets;
361 struct _xmlSchemaType *redef;/* possible redefinitions for the type */
367 * An element definition.
369 * xmlSchemaType, xmlSchemaFacet and xmlSchemaElement start of
370 * structures must be kept similar
373 * XML_SCHEMAS_ELEM_NILLABLE:
375 * the element is nillable
377 #define XML_SCHEMAS_ELEM_NILLABLE 1 << 0
379 * XML_SCHEMAS_ELEM_GLOBAL:
381 * the element is global
383 #define XML_SCHEMAS_ELEM_GLOBAL 1 << 1
385 * XML_SCHEMAS_ELEM_DEFAULT:
387 * the element has a default value
389 #define XML_SCHEMAS_ELEM_DEFAULT 1 << 2
391 * XML_SCHEMAS_ELEM_FIXED:
393 * the element has a fixed value
395 #define XML_SCHEMAS_ELEM_FIXED 1 << 3
397 * XML_SCHEMAS_ELEM_ABSTRACT:
399 * the element is abstract
401 #define XML_SCHEMAS_ELEM_ABSTRACT 1 << 4
403 * XML_SCHEMAS_ELEM_TOPLEVEL:
405 * the element is top level
407 #define XML_SCHEMAS_ELEM_TOPLEVEL 1 << 5
409 * XML_SCHEMAS_ELEM_REF:
411 * the element is a reference to a type
413 #define XML_SCHEMAS_ELEM_REF 1 << 6
415 * XML_SCHEMAS_ELEM_NSDEFAULT:
417 * allow elements in no namespace
419 #define XML_SCHEMAS_ELEM_NSDEFAULT 1 << 7
421 typedef struct _xmlSchemaElement xmlSchemaElement;
422 typedef xmlSchemaElement *xmlSchemaElementPtr;
423 struct _xmlSchemaElement {
424 xmlSchemaTypeType type; /* The kind of type */
425 struct _xmlSchemaType *next;/* the next type if in a sequence ... */
429 const xmlChar *refNs;
430 xmlSchemaAnnotPtr annot;
431 xmlSchemaTypePtr subtypes;
432 xmlSchemaAttributePtr attributes;
438 const xmlChar *targetNamespace;
439 const xmlChar *namedType;
440 const xmlChar *namedTypeNs;
441 const xmlChar *substGroup;
442 const xmlChar *substGroupNs;
443 const xmlChar *scope;
444 const xmlChar *value;
445 struct _xmlSchemaElement *refDecl;
446 #ifdef LIBXML_REGEXP_ENABLED
447 xmlRegexpPtr contModel;
449 xmlSchemaContentType contentType;
453 * XML_SCHEMAS_FACET_UNKNOWN:
455 * unknown facet handling
457 #define XML_SCHEMAS_FACET_UNKNOWN 0
459 * XML_SCHEMAS_FACET_PRESERVE:
461 * preserve the type of the facet
463 #define XML_SCHEMAS_FACET_PRESERVE 1
465 * XML_SCHEMAS_FACET_REPLACE:
467 * replace the type of the facet
469 #define XML_SCHEMAS_FACET_REPLACE 2
471 * XML_SCHEMAS_FACET_COLLAPSE:
473 * collapse the types of the facet
475 #define XML_SCHEMAS_FACET_COLLAPSE 3
478 * A facet definition.
480 struct _xmlSchemaFacet {
481 xmlSchemaTypeType type; /* The kind of type */
482 struct _xmlSchemaFacet *next;/* the next type if in a sequence ... */
483 const xmlChar *value;
485 xmlSchemaAnnotPtr annot;
490 #ifdef LIBXML_REGEXP_ENABLED
496 * A notation definition.
498 typedef struct _xmlSchemaNotation xmlSchemaNotation;
499 typedef xmlSchemaNotation *xmlSchemaNotationPtr;
500 struct _xmlSchemaNotation {
501 xmlSchemaTypeType type; /* The kind of type */
503 xmlSchemaAnnotPtr annot;
504 const xmlChar *identifier;
508 * XML_SCHEMAS_QUALIF_ELEM:
510 * the shemas requires qualified elements
512 #define XML_SCHEMAS_QUALIF_ELEM 1 << 0
514 * XML_SCHEMAS_QUALIF_ATTR:
516 * the shemas requires qualified attributes
518 #define XML_SCHEMAS_QUALIF_ATTR 1 << 1
522 * A Schemas definition
525 const xmlChar *name; /* schema name */
526 const xmlChar *targetNamespace; /* the target namespace */
527 const xmlChar *version;
530 xmlSchemaAnnotPtr annot;
533 xmlHashTablePtr typeDecl;
534 xmlHashTablePtr attrDecl;
535 xmlHashTablePtr attrgrpDecl;
536 xmlHashTablePtr elemDecl;
537 xmlHashTablePtr notaDecl;
539 xmlHashTablePtr schemasImports;
541 void *_private; /* unused by the library for users or bindings */
542 xmlHashTablePtr groupDecl;
544 void *includes; /* the includes, this is opaque for now */
545 int preserve; /* whether to free the document */
548 XMLPUBFUN void XMLCALL xmlSchemaFreeType (xmlSchemaTypePtr type);
554 #endif /* #if defined(LIBXML_SCHEMAS_ENABLED) || defined(XMLENGINE_XMLSCHEMA_DATATYPES) */
555 #endif /* XML_SCHEMA_INTERNALS_H */