1 /* libxml2 - Library for parsing XML documents
2  * Copyright (C) 2006-2019 Free Software Foundation, Inc.
3  *
4  * This file is not part of the GNU gettext program, but is used with
5  * GNU gettext.
6  *
7  * The original copyright notice is as follows:
8  */
9 
10 /*
11  * Copyright (C) 1998-2012 Daniel Veillard.  All Rights Reserved.
12  *
13  * Permission is hereby granted, free of charge, to any person obtaining a copy
14  * of this software and associated documentation files (the "Software"), to deal
15  * in the Software without restriction, including without limitation the rights
16  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17  * copies of the Software, and to permit persons to whom the Software is fur-
18  * nished to do so, subject to the following conditions:
19  *
20  * The above copyright notice and this permission notice shall be included in
21  * all copies or substantial portions of the Software.
22  *
23  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FIT-
25  * NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
26  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
29  * THE SOFTWARE.
30  *
31  * Author: Daniel Veillard
32  */
33 
34 /*
35  * Summary: internal interfaces for XML Schemas
36  * Description: internal interfaces for the XML Schemas handling
37  *              and schema validity checking
38  *		The Schemas development is a Work In Progress.
39  *              Some of those interfaces are not guaranteed to be API or ABI stable !
40  */
41 
42 #ifndef __XML_SCHEMA_INTERNALS_H__
43 #define __XML_SCHEMA_INTERNALS_H__
44 
45 #include <libxml/xmlversion.h>
46 
47 #ifdef LIBXML_SCHEMAS_ENABLED
48 
49 #include <libxml/xmlregexp.h>
50 #include <libxml/hash.h>
51 #include <libxml/dict.h>
52 
53 #ifdef __cplusplus
54 extern "C" {
55 #endif
56 
57 typedef enum {
58     XML_SCHEMAS_UNKNOWN = 0,
59     XML_SCHEMAS_STRING = 1,
60     XML_SCHEMAS_NORMSTRING = 2,
61     XML_SCHEMAS_DECIMAL = 3,
62     XML_SCHEMAS_TIME = 4,
63     XML_SCHEMAS_GDAY = 5,
64     XML_SCHEMAS_GMONTH = 6,
65     XML_SCHEMAS_GMONTHDAY = 7,
66     XML_SCHEMAS_GYEAR = 8,
67     XML_SCHEMAS_GYEARMONTH = 9,
68     XML_SCHEMAS_DATE = 10,
69     XML_SCHEMAS_DATETIME = 11,
70     XML_SCHEMAS_DURATION = 12,
71     XML_SCHEMAS_FLOAT = 13,
72     XML_SCHEMAS_DOUBLE = 14,
73     XML_SCHEMAS_BOOLEAN = 15,
74     XML_SCHEMAS_TOKEN = 16,
75     XML_SCHEMAS_LANGUAGE = 17,
76     XML_SCHEMAS_NMTOKEN = 18,
77     XML_SCHEMAS_NMTOKENS = 19,
78     XML_SCHEMAS_NAME = 20,
79     XML_SCHEMAS_QNAME = 21,
80     XML_SCHEMAS_NCNAME = 22,
81     XML_SCHEMAS_ID = 23,
82     XML_SCHEMAS_IDREF = 24,
83     XML_SCHEMAS_IDREFS = 25,
84     XML_SCHEMAS_ENTITY = 26,
85     XML_SCHEMAS_ENTITIES = 27,
86     XML_SCHEMAS_NOTATION = 28,
87     XML_SCHEMAS_ANYURI = 29,
88     XML_SCHEMAS_INTEGER = 30,
89     XML_SCHEMAS_NPINTEGER = 31,
90     XML_SCHEMAS_NINTEGER = 32,
91     XML_SCHEMAS_NNINTEGER = 33,
92     XML_SCHEMAS_PINTEGER = 34,
93     XML_SCHEMAS_INT = 35,
94     XML_SCHEMAS_UINT = 36,
95     XML_SCHEMAS_LONG = 37,
96     XML_SCHEMAS_ULONG = 38,
97     XML_SCHEMAS_SHORT = 39,
98     XML_SCHEMAS_USHORT = 40,
99     XML_SCHEMAS_BYTE = 41,
100     XML_SCHEMAS_UBYTE = 42,
101     XML_SCHEMAS_HEXBINARY = 43,
102     XML_SCHEMAS_BASE64BINARY = 44,
103     XML_SCHEMAS_ANYTYPE = 45,
104     XML_SCHEMAS_ANYSIMPLETYPE = 46
105 } xmlSchemaValType;
106 
107 /*
108  * XML Schemas defines multiple type of types.
109  */
110 typedef enum {
111     XML_SCHEMA_TYPE_BASIC = 1, /* A built-in datatype */
112     XML_SCHEMA_TYPE_ANY,
113     XML_SCHEMA_TYPE_FACET,
114     XML_SCHEMA_TYPE_SIMPLE,
115     XML_SCHEMA_TYPE_COMPLEX,
116     XML_SCHEMA_TYPE_SEQUENCE = 6,
117     XML_SCHEMA_TYPE_CHOICE,
118     XML_SCHEMA_TYPE_ALL,
119     XML_SCHEMA_TYPE_SIMPLE_CONTENT,
120     XML_SCHEMA_TYPE_COMPLEX_CONTENT,
121     XML_SCHEMA_TYPE_UR,
122     XML_SCHEMA_TYPE_RESTRICTION,
123     XML_SCHEMA_TYPE_EXTENSION,
124     XML_SCHEMA_TYPE_ELEMENT,
125     XML_SCHEMA_TYPE_ATTRIBUTE,
126     XML_SCHEMA_TYPE_ATTRIBUTEGROUP,
127     XML_SCHEMA_TYPE_GROUP,
128     XML_SCHEMA_TYPE_NOTATION,
129     XML_SCHEMA_TYPE_LIST,
130     XML_SCHEMA_TYPE_UNION,
131     XML_SCHEMA_TYPE_ANY_ATTRIBUTE,
132     XML_SCHEMA_TYPE_IDC_UNIQUE,
133     XML_SCHEMA_TYPE_IDC_KEY,
134     XML_SCHEMA_TYPE_IDC_KEYREF,
135     XML_SCHEMA_TYPE_PARTICLE = 25,
136     XML_SCHEMA_TYPE_ATTRIBUTE_USE,
137     XML_SCHEMA_FACET_MININCLUSIVE = 1000,
138     XML_SCHEMA_FACET_MINEXCLUSIVE,
139     XML_SCHEMA_FACET_MAXINCLUSIVE,
140     XML_SCHEMA_FACET_MAXEXCLUSIVE,
141     XML_SCHEMA_FACET_TOTALDIGITS,
142     XML_SCHEMA_FACET_FRACTIONDIGITS,
143     XML_SCHEMA_FACET_PATTERN,
144     XML_SCHEMA_FACET_ENUMERATION,
145     XML_SCHEMA_FACET_WHITESPACE,
146     XML_SCHEMA_FACET_LENGTH,
147     XML_SCHEMA_FACET_MAXLENGTH,
148     XML_SCHEMA_FACET_MINLENGTH,
149     XML_SCHEMA_EXTRA_QNAMEREF = 2000,
150     XML_SCHEMA_EXTRA_ATTR_USE_PROHIB
151 } xmlSchemaTypeType;
152 
153 typedef enum {
154     XML_SCHEMA_CONTENT_UNKNOWN = 0,
155     XML_SCHEMA_CONTENT_EMPTY = 1,
156     XML_SCHEMA_CONTENT_ELEMENTS,
157     XML_SCHEMA_CONTENT_MIXED,
158     XML_SCHEMA_CONTENT_SIMPLE,
159     XML_SCHEMA_CONTENT_MIXED_OR_ELEMENTS, /* Obsolete */
160     XML_SCHEMA_CONTENT_BASIC,
161     XML_SCHEMA_CONTENT_ANY
162 } xmlSchemaContentType;
163 
164 typedef struct _xmlSchemaVal xmlSchemaVal;
165 typedef xmlSchemaVal *xmlSchemaValPtr;
166 
167 typedef struct _xmlSchemaType xmlSchemaType;
168 typedef xmlSchemaType *xmlSchemaTypePtr;
169 
170 typedef struct _xmlSchemaFacet xmlSchemaFacet;
171 typedef xmlSchemaFacet *xmlSchemaFacetPtr;
172 
173 /**
174  * Annotation
175  */
176 typedef struct _xmlSchemaAnnot xmlSchemaAnnot;
177 typedef xmlSchemaAnnot *xmlSchemaAnnotPtr;
178 struct _xmlSchemaAnnot {
179     struct _xmlSchemaAnnot *next;
180     xmlNodePtr content;         /* the annotation */
181 };
182 
183 /**
184  * XML_SCHEMAS_ANYATTR_SKIP:
185  *
186  * Skip unknown attribute from validation
187  * Obsolete, not used anymore.
188  */
189 #define XML_SCHEMAS_ANYATTR_SKIP        1
190 /**
191  * XML_SCHEMAS_ANYATTR_LAX:
192  *
193  * Ignore validation non definition on attributes
194  * Obsolete, not used anymore.
195  */
196 #define XML_SCHEMAS_ANYATTR_LAX                2
197 /**
198  * XML_SCHEMAS_ANYATTR_STRICT:
199  *
200  * Apply strict validation rules on attributes
201  * Obsolete, not used anymore.
202  */
203 #define XML_SCHEMAS_ANYATTR_STRICT        3
204 /**
205  * XML_SCHEMAS_ANY_SKIP:
206  *
207  * Skip unknown attribute from validation
208  */
209 #define XML_SCHEMAS_ANY_SKIP        1
210 /**
211  * XML_SCHEMAS_ANY_LAX:
212  *
213  * Used by wildcards.
214  * Validate if type found, don't worry if not found
215  */
216 #define XML_SCHEMAS_ANY_LAX                2
217 /**
218  * XML_SCHEMAS_ANY_STRICT:
219  *
220  * Used by wildcards.
221  * Apply strict validation rules
222  */
223 #define XML_SCHEMAS_ANY_STRICT        3
224 /**
225  * XML_SCHEMAS_ATTR_USE_PROHIBITED:
226  *
227  * Used by wildcards.
228  * The attribute is prohibited.
229  */
230 #define XML_SCHEMAS_ATTR_USE_PROHIBITED 0
231 /**
232  * XML_SCHEMAS_ATTR_USE_REQUIRED:
233  *
234  * The attribute is required.
235  */
236 #define XML_SCHEMAS_ATTR_USE_REQUIRED 1
237 /**
238  * XML_SCHEMAS_ATTR_USE_OPTIONAL:
239  *
240  * The attribute is optional.
241  */
242 #define XML_SCHEMAS_ATTR_USE_OPTIONAL 2
243 /**
244  * XML_SCHEMAS_ATTR_GLOBAL:
245  *
246  * allow elements in no namespace
247  */
248 #define XML_SCHEMAS_ATTR_GLOBAL        1 << 0
249 /**
250  * XML_SCHEMAS_ATTR_NSDEFAULT:
251  *
252  * allow elements in no namespace
253  */
254 #define XML_SCHEMAS_ATTR_NSDEFAULT        1 << 7
255 /**
256  * XML_SCHEMAS_ATTR_INTERNAL_RESOLVED:
257  *
258  * this is set when the "type" and "ref" references
259  * have been resolved.
260  */
261 #define XML_SCHEMAS_ATTR_INTERNAL_RESOLVED        1 << 8
262 /**
263  * XML_SCHEMAS_ATTR_FIXED:
264  *
265  * the attribute has a fixed value
266  */
267 #define XML_SCHEMAS_ATTR_FIXED        1 << 9
268 
269 /**
270  * xmlSchemaAttribute:
271  * An attribute definition.
272  */
273 
274 typedef struct _xmlSchemaAttribute xmlSchemaAttribute;
275 typedef xmlSchemaAttribute *xmlSchemaAttributePtr;
276 struct _xmlSchemaAttribute {
277     xmlSchemaTypeType type;
278     struct _xmlSchemaAttribute *next; /* the next attribute (not used?) */
279     const xmlChar *name; /* the name of the declaration */
280     const xmlChar *id; /* Deprecated; not used */
281     const xmlChar *ref; /* Deprecated; not used */
282     const xmlChar *refNs; /* Deprecated; not used */
283     const xmlChar *typeName; /* the local name of the type definition */
284     const xmlChar *typeNs; /* the ns URI of the type definition */
285     xmlSchemaAnnotPtr annot;
286 
287     xmlSchemaTypePtr base; /* Deprecated; not used */
288     int occurs; /* Deprecated; not used */
289     const xmlChar *defValue; /* The initial value of the value constraint */
290     xmlSchemaTypePtr subtypes; /* the type definition */
291     xmlNodePtr node;
292     const xmlChar *targetNamespace;
293     int flags;
294     const xmlChar *refPrefix; /* Deprecated; not used */
295     xmlSchemaValPtr defVal; /* The compiled value constraint */
296     xmlSchemaAttributePtr refDecl; /* Deprecated; not used */
297 };
298 
299 /**
300  * xmlSchemaAttributeLink:
301  * Used to build a list of attribute uses on complexType definitions.
302  * WARNING: Deprecated; not used.
303  */
304 typedef struct _xmlSchemaAttributeLink xmlSchemaAttributeLink;
305 typedef xmlSchemaAttributeLink *xmlSchemaAttributeLinkPtr;
306 struct _xmlSchemaAttributeLink {
307     struct _xmlSchemaAttributeLink *next;/* the next attribute link ... */
308     struct _xmlSchemaAttribute *attr;/* the linked attribute */
309 };
310 
311 /**
312  * XML_SCHEMAS_WILDCARD_COMPLETE:
313  *
314  * If the wildcard is complete.
315  */
316 #define XML_SCHEMAS_WILDCARD_COMPLETE 1 << 0
317 
318 /**
319  * xmlSchemaCharValueLink:
320  * Used to build a list of namespaces on wildcards.
321  */
322 typedef struct _xmlSchemaWildcardNs xmlSchemaWildcardNs;
323 typedef xmlSchemaWildcardNs *xmlSchemaWildcardNsPtr;
324 struct _xmlSchemaWildcardNs {
325     struct _xmlSchemaWildcardNs *next;/* the next constraint link ... */
326     const xmlChar *value;/* the value */
327 };
328 
329 /**
330  * xmlSchemaWildcard.
331  * A wildcard.
332  */
333 typedef struct _xmlSchemaWildcard xmlSchemaWildcard;
334 typedef xmlSchemaWildcard *xmlSchemaWildcardPtr;
335 struct _xmlSchemaWildcard {
336     xmlSchemaTypeType type;        /* The kind of type */
337     const xmlChar *id; /* Deprecated; not used */
338     xmlSchemaAnnotPtr annot;
339     xmlNodePtr node;
340     int minOccurs; /* Deprecated; not used */
341     int maxOccurs; /* Deprecated; not used */
342     int processContents;
343     int any; /* Indicates if the ns constraint is of ##any */
344     xmlSchemaWildcardNsPtr nsSet; /* The list of allowed namespaces */
345     xmlSchemaWildcardNsPtr negNsSet; /* The negated namespace */
346     int flags;
347 };
348 
349 /**
350  * XML_SCHEMAS_ATTRGROUP_WILDCARD_BUILDED:
351  *
352  * The attribute wildcard has been already builded.
353  */
354 #define XML_SCHEMAS_ATTRGROUP_WILDCARD_BUILDED 1 << 0
355 /**
356  * XML_SCHEMAS_ATTRGROUP_GLOBAL:
357  *
358  * The attribute wildcard has been already builded.
359  */
360 #define XML_SCHEMAS_ATTRGROUP_GLOBAL 1 << 1
361 /**
362  * XML_SCHEMAS_ATTRGROUP_MARKED:
363  *
364  * Marks the attr group as marked; used for circular checks.
365  */
366 #define XML_SCHEMAS_ATTRGROUP_MARKED 1 << 2
367 
368 /**
369  * XML_SCHEMAS_ATTRGROUP_REDEFINED:
370  *
371  * The attr group was redefined.
372  */
373 #define XML_SCHEMAS_ATTRGROUP_REDEFINED 1 << 3
374 /**
375  * XML_SCHEMAS_ATTRGROUP_HAS_REFS:
376  *
377  * Whether this attr. group contains attr. group references.
378  */
379 #define XML_SCHEMAS_ATTRGROUP_HAS_REFS 1 << 4
380 
381 /**
382  * An attribute group definition.
383  *
384  * xmlSchemaAttribute and xmlSchemaAttributeGroup start of structures
385  * must be kept similar
386  */
387 typedef struct _xmlSchemaAttributeGroup xmlSchemaAttributeGroup;
388 typedef xmlSchemaAttributeGroup *xmlSchemaAttributeGroupPtr;
389 struct _xmlSchemaAttributeGroup {
390     xmlSchemaTypeType type;        /* The kind of type */
391     struct _xmlSchemaAttribute *next;/* the next attribute if in a group ... */
392     const xmlChar *name;
393     const xmlChar *id;
394     const xmlChar *ref; /* Deprecated; not used */
395     const xmlChar *refNs; /* Deprecated; not used */
396     xmlSchemaAnnotPtr annot;
397 
398     xmlSchemaAttributePtr attributes; /* Deprecated; not used */
399     xmlNodePtr node;
400     int flags;
401     xmlSchemaWildcardPtr attributeWildcard;
402     const xmlChar *refPrefix; /* Deprecated; not used */
403     xmlSchemaAttributeGroupPtr refItem; /* Deprecated; not used */
404     const xmlChar *targetNamespace;
405     void *attrUses;
406 };
407 
408 /**
409  * xmlSchemaTypeLink:
410  * Used to build a list of types (e.g. member types of
411  * simpleType with variety "union").
412  */
413 typedef struct _xmlSchemaTypeLink xmlSchemaTypeLink;
414 typedef xmlSchemaTypeLink *xmlSchemaTypeLinkPtr;
415 struct _xmlSchemaTypeLink {
416     struct _xmlSchemaTypeLink *next;/* the next type link ... */
417     xmlSchemaTypePtr type;/* the linked type */
418 };
419 
420 /**
421  * xmlSchemaFacetLink:
422  * Used to build a list of facets.
423  */
424 typedef struct _xmlSchemaFacetLink xmlSchemaFacetLink;
425 typedef xmlSchemaFacetLink *xmlSchemaFacetLinkPtr;
426 struct _xmlSchemaFacetLink {
427     struct _xmlSchemaFacetLink *next;/* the next facet link ... */
428     xmlSchemaFacetPtr facet;/* the linked facet */
429 };
430 
431 /**
432  * XML_SCHEMAS_TYPE_MIXED:
433  *
434  * the element content type is mixed
435  */
436 #define XML_SCHEMAS_TYPE_MIXED                1 << 0
437 /**
438  * XML_SCHEMAS_TYPE_DERIVATION_METHOD_EXTENSION:
439  *
440  * the simple or complex type has a derivation method of "extension".
441  */
442 #define XML_SCHEMAS_TYPE_DERIVATION_METHOD_EXTENSION                1 << 1
443 /**
444  * XML_SCHEMAS_TYPE_DERIVATION_METHOD_RESTRICTION:
445  *
446  * the simple or complex type has a derivation method of "restriction".
447  */
448 #define XML_SCHEMAS_TYPE_DERIVATION_METHOD_RESTRICTION                1 << 2
449 /**
450  * XML_SCHEMAS_TYPE_GLOBAL:
451  *
452  * the type is global
453  */
454 #define XML_SCHEMAS_TYPE_GLOBAL                1 << 3
455 /**
456  * XML_SCHEMAS_TYPE_OWNED_ATTR_WILDCARD:
457  *
458  * the complexType owns an attribute wildcard, i.e.
459  * it can be freed by the complexType
460  */
461 #define XML_SCHEMAS_TYPE_OWNED_ATTR_WILDCARD    1 << 4 /* Obsolete. */
462 /**
463  * XML_SCHEMAS_TYPE_VARIETY_ABSENT:
464  *
465  * the simpleType has a variety of "absent".
466  * TODO: Actually not necessary :-/, since if
467  * none of the variety flags occur then it's
468  * automatically absent.
469  */
470 #define XML_SCHEMAS_TYPE_VARIETY_ABSENT    1 << 5
471 /**
472  * XML_SCHEMAS_TYPE_VARIETY_LIST:
473  *
474  * the simpleType has a variety of "list".
475  */
476 #define XML_SCHEMAS_TYPE_VARIETY_LIST    1 << 6
477 /**
478  * XML_SCHEMAS_TYPE_VARIETY_UNION:
479  *
480  * the simpleType has a variety of "union".
481  */
482 #define XML_SCHEMAS_TYPE_VARIETY_UNION    1 << 7
483 /**
484  * XML_SCHEMAS_TYPE_VARIETY_ATOMIC:
485  *
486  * the simpleType has a variety of "union".
487  */
488 #define XML_SCHEMAS_TYPE_VARIETY_ATOMIC    1 << 8
489 /**
490  * XML_SCHEMAS_TYPE_FINAL_EXTENSION:
491  *
492  * the complexType has a final of "extension".
493  */
494 #define XML_SCHEMAS_TYPE_FINAL_EXTENSION    1 << 9
495 /**
496  * XML_SCHEMAS_TYPE_FINAL_RESTRICTION:
497  *
498  * the simpleType/complexType has a final of "restriction".
499  */
500 #define XML_SCHEMAS_TYPE_FINAL_RESTRICTION    1 << 10
501 /**
502  * XML_SCHEMAS_TYPE_FINAL_LIST:
503  *
504  * the simpleType has a final of "list".
505  */
506 #define XML_SCHEMAS_TYPE_FINAL_LIST    1 << 11
507 /**
508  * XML_SCHEMAS_TYPE_FINAL_UNION:
509  *
510  * the simpleType has a final of "union".
511  */
512 #define XML_SCHEMAS_TYPE_FINAL_UNION    1 << 12
513 /**
514  * XML_SCHEMAS_TYPE_FINAL_DEFAULT:
515  *
516  * the simpleType has a final of "default".
517  */
518 #define XML_SCHEMAS_TYPE_FINAL_DEFAULT    1 << 13
519 /**
520  * XML_SCHEMAS_TYPE_BUILTIN_PRIMITIVE:
521  *
522  * Marks the item as a builtin primitive.
523  */
524 #define XML_SCHEMAS_TYPE_BUILTIN_PRIMITIVE    1 << 14
525 /**
526  * XML_SCHEMAS_TYPE_MARKED:
527  *
528  * Marks the item as marked; used for circular checks.
529  */
530 #define XML_SCHEMAS_TYPE_MARKED        1 << 16
531 /**
532  * XML_SCHEMAS_TYPE_BLOCK_DEFAULT:
533  *
534  * the complexType did not specify 'block' so use the default of the
535  * <schema> item.
536  */
537 #define XML_SCHEMAS_TYPE_BLOCK_DEFAULT    1 << 17
538 /**
539  * XML_SCHEMAS_TYPE_BLOCK_EXTENSION:
540  *
541  * the complexType has a 'block' of "extension".
542  */
543 #define XML_SCHEMAS_TYPE_BLOCK_EXTENSION    1 << 18
544 /**
545  * XML_SCHEMAS_TYPE_BLOCK_RESTRICTION:
546  *
547  * the complexType has a 'block' of "restriction".
548  */
549 #define XML_SCHEMAS_TYPE_BLOCK_RESTRICTION    1 << 19
550 /**
551  * XML_SCHEMAS_TYPE_ABSTRACT:
552  *
553  * the simple/complexType is abstract.
554  */
555 #define XML_SCHEMAS_TYPE_ABSTRACT    1 << 20
556 /**
557  * XML_SCHEMAS_TYPE_FACETSNEEDVALUE:
558  *
559  * indicates if the facets need a computed value
560  */
561 #define XML_SCHEMAS_TYPE_FACETSNEEDVALUE    1 << 21
562 /**
563  * XML_SCHEMAS_TYPE_INTERNAL_RESOLVED:
564  *
565  * indicates that the type was typefixed
566  */
567 #define XML_SCHEMAS_TYPE_INTERNAL_RESOLVED    1 << 22
568 /**
569  * XML_SCHEMAS_TYPE_INTERNAL_INVALID:
570  *
571  * indicates that the type is invalid
572  */
573 #define XML_SCHEMAS_TYPE_INTERNAL_INVALID    1 << 23
574 /**
575  * XML_SCHEMAS_TYPE_WHITESPACE_PRESERVE:
576  *
577  * a whitespace-facet value of "preserve"
578  */
579 #define XML_SCHEMAS_TYPE_WHITESPACE_PRESERVE    1 << 24
580 /**
581  * XML_SCHEMAS_TYPE_WHITESPACE_REPLACE:
582  *
583  * a whitespace-facet value of "replace"
584  */
585 #define XML_SCHEMAS_TYPE_WHITESPACE_REPLACE    1 << 25
586 /**
587  * XML_SCHEMAS_TYPE_WHITESPACE_COLLAPSE:
588  *
589  * a whitespace-facet value of "collapse"
590  */
591 #define XML_SCHEMAS_TYPE_WHITESPACE_COLLAPSE    1 << 26
592 /**
593  * XML_SCHEMAS_TYPE_HAS_FACETS:
594  *
595  * has facets
596  */
597 #define XML_SCHEMAS_TYPE_HAS_FACETS    1 << 27
598 /**
599  * XML_SCHEMAS_TYPE_NORMVALUENEEDED:
600  *
601  * indicates if the facets (pattern) need a normalized value
602  */
603 #define XML_SCHEMAS_TYPE_NORMVALUENEEDED    1 << 28
604 
605 /**
606  * XML_SCHEMAS_TYPE_FIXUP_1:
607  *
608  * First stage of fixup was done.
609  */
610 #define XML_SCHEMAS_TYPE_FIXUP_1    1 << 29
611 
612 /**
613  * XML_SCHEMAS_TYPE_REDEFINED:
614  *
615  * The type was redefined.
616  */
617 #define XML_SCHEMAS_TYPE_REDEFINED    1 << 30
618 /**
619  * XML_SCHEMAS_TYPE_REDEFINING:
620  *
621  * The type redefines an other type.
622  */
623 /* #define XML_SCHEMAS_TYPE_REDEFINING    1 << 31 */
624 
625 /**
626  * _xmlSchemaType:
627  *
628  * Schemas type definition.
629  */
630 struct _xmlSchemaType {
631     xmlSchemaTypeType type; /* The kind of type */
632     struct _xmlSchemaType *next; /* the next type if in a sequence ... */
633     const xmlChar *name;
634     const xmlChar *id ; /* Deprecated; not used */
635     const xmlChar *ref; /* Deprecated; not used */
636     const xmlChar *refNs; /* Deprecated; not used */
637     xmlSchemaAnnotPtr annot;
638     xmlSchemaTypePtr subtypes;
639     xmlSchemaAttributePtr attributes; /* Deprecated; not used */
640     xmlNodePtr node;
641     int minOccurs; /* Deprecated; not used */
642     int maxOccurs; /* Deprecated; not used */
643 
644     int flags;
645     xmlSchemaContentType contentType;
646     const xmlChar *base; /* Base type's local name */
647     const xmlChar *baseNs; /* Base type's target namespace */
648     xmlSchemaTypePtr baseType; /* The base type component */
649     xmlSchemaFacetPtr facets; /* Local facets */
650     struct _xmlSchemaType *redef; /* Deprecated; not used */
651     int recurse; /* Obsolete */
652     xmlSchemaAttributeLinkPtr *attributeUses; /* Deprecated; not used */
653     xmlSchemaWildcardPtr attributeWildcard;
654     int builtInType; /* Type of built-in types. */
655     xmlSchemaTypeLinkPtr memberTypes; /* member-types if a union type. */
656     xmlSchemaFacetLinkPtr facetSet; /* All facets (incl. inherited) */
657     const xmlChar *refPrefix; /* Deprecated; not used */
658     xmlSchemaTypePtr contentTypeDef; /* Used for the simple content of complex types.
659                                         Could we use @subtypes for this? */
660     xmlRegexpPtr contModel; /* Holds the automaton of the content model */
661     const xmlChar *targetNamespace;
662     void *attrUses;
663 };
664 
665 /*
666  * xmlSchemaElement:
667  * An element definition.
668  *
669  * xmlSchemaType, xmlSchemaFacet and xmlSchemaElement start of
670  * structures must be kept similar
671  */
672 /**
673  * XML_SCHEMAS_ELEM_NILLABLE:
674  *
675  * the element is nillable
676  */
677 #define XML_SCHEMAS_ELEM_NILLABLE        1 << 0
678 /**
679  * XML_SCHEMAS_ELEM_GLOBAL:
680  *
681  * the element is global
682  */
683 #define XML_SCHEMAS_ELEM_GLOBAL                1 << 1
684 /**
685  * XML_SCHEMAS_ELEM_DEFAULT:
686  *
687  * the element has a default value
688  */
689 #define XML_SCHEMAS_ELEM_DEFAULT        1 << 2
690 /**
691  * XML_SCHEMAS_ELEM_FIXED:
692  *
693  * the element has a fixed value
694  */
695 #define XML_SCHEMAS_ELEM_FIXED                1 << 3
696 /**
697  * XML_SCHEMAS_ELEM_ABSTRACT:
698  *
699  * the element is abstract
700  */
701 #define XML_SCHEMAS_ELEM_ABSTRACT        1 << 4
702 /**
703  * XML_SCHEMAS_ELEM_TOPLEVEL:
704  *
705  * the element is top level
706  * obsolete: use XML_SCHEMAS_ELEM_GLOBAL instead
707  */
708 #define XML_SCHEMAS_ELEM_TOPLEVEL        1 << 5
709 /**
710  * XML_SCHEMAS_ELEM_REF:
711  *
712  * the element is a reference to a type
713  */
714 #define XML_SCHEMAS_ELEM_REF                1 << 6
715 /**
716  * XML_SCHEMAS_ELEM_NSDEFAULT:
717  *
718  * allow elements in no namespace
719  * Obsolete, not used anymore.
720  */
721 #define XML_SCHEMAS_ELEM_NSDEFAULT        1 << 7
722 /**
723  * XML_SCHEMAS_ELEM_INTERNAL_RESOLVED:
724  *
725  * this is set when "type", "ref", "substitutionGroup"
726  * references have been resolved.
727  */
728 #define XML_SCHEMAS_ELEM_INTERNAL_RESOLVED        1 << 8
729  /**
730  * XML_SCHEMAS_ELEM_CIRCULAR:
731  *
732  * a helper flag for the search of circular references.
733  */
734 #define XML_SCHEMAS_ELEM_CIRCULAR        1 << 9
735 /**
736  * XML_SCHEMAS_ELEM_BLOCK_ABSENT:
737  *
738  * the "block" attribute is absent
739  */
740 #define XML_SCHEMAS_ELEM_BLOCK_ABSENT        1 << 10
741 /**
742  * XML_SCHEMAS_ELEM_BLOCK_EXTENSION:
743  *
744  * disallowed substitutions are absent
745  */
746 #define XML_SCHEMAS_ELEM_BLOCK_EXTENSION        1 << 11
747 /**
748  * XML_SCHEMAS_ELEM_BLOCK_RESTRICTION:
749  *
750  * disallowed substitutions: "restriction"
751  */
752 #define XML_SCHEMAS_ELEM_BLOCK_RESTRICTION        1 << 12
753 /**
754  * XML_SCHEMAS_ELEM_BLOCK_SUBSTITUTION:
755  *
756  * disallowed substitutions: "substituion"
757  */
758 #define XML_SCHEMAS_ELEM_BLOCK_SUBSTITUTION        1 << 13
759 /**
760  * XML_SCHEMAS_ELEM_FINAL_ABSENT:
761  *
762  * substitution group exclusions are absent
763  */
764 #define XML_SCHEMAS_ELEM_FINAL_ABSENT        1 << 14
765 /**
766  * XML_SCHEMAS_ELEM_FINAL_EXTENSION:
767  *
768  * substitution group exclusions: "extension"
769  */
770 #define XML_SCHEMAS_ELEM_FINAL_EXTENSION        1 << 15
771 /**
772  * XML_SCHEMAS_ELEM_FINAL_RESTRICTION:
773  *
774  * substitution group exclusions: "restriction"
775  */
776 #define XML_SCHEMAS_ELEM_FINAL_RESTRICTION        1 << 16
777 /**
778  * XML_SCHEMAS_ELEM_SUBST_GROUP_HEAD:
779  *
780  * the declaration is a substitution group head
781  */
782 #define XML_SCHEMAS_ELEM_SUBST_GROUP_HEAD        1 << 17
783 /**
784  * XML_SCHEMAS_ELEM_INTERNAL_CHECKED:
785  *
786  * this is set when the elem decl has been checked against
787  * all constraints
788  */
789 #define XML_SCHEMAS_ELEM_INTERNAL_CHECKED        1 << 18
790 
791 typedef struct _xmlSchemaElement xmlSchemaElement;
792 typedef xmlSchemaElement *xmlSchemaElementPtr;
793 struct _xmlSchemaElement {
794     xmlSchemaTypeType type; /* The kind of type */
795     struct _xmlSchemaType *next; /* Not used? */
796     const xmlChar *name;
797     const xmlChar *id; /* Deprecated; not used */
798     const xmlChar *ref; /* Deprecated; not used */
799     const xmlChar *refNs; /* Deprecated; not used */
800     xmlSchemaAnnotPtr annot;
801     xmlSchemaTypePtr subtypes; /* the type definition */
802     xmlSchemaAttributePtr attributes;
803     xmlNodePtr node;
804     int minOccurs; /* Deprecated; not used */
805     int maxOccurs; /* Deprecated; not used */
806 
807     int flags;
808     const xmlChar *targetNamespace;
809     const xmlChar *namedType;
810     const xmlChar *namedTypeNs;
811     const xmlChar *substGroup;
812     const xmlChar *substGroupNs;
813     const xmlChar *scope;
814     const xmlChar *value; /* The original value of the value constraint. */
815     struct _xmlSchemaElement *refDecl; /* This will now be used for the
816                                           substitution group affiliation */
817     xmlRegexpPtr contModel; /* Obsolete for WXS, maybe used for RelaxNG */
818     xmlSchemaContentType contentType;
819     const xmlChar *refPrefix; /* Deprecated; not used */
820     xmlSchemaValPtr defVal; /* The compiled value contraint. */
821     void *idcs; /* The identity-constraint defs */
822 };
823 
824 /*
825  * XML_SCHEMAS_FACET_UNKNOWN:
826  *
827  * unknown facet handling
828  */
829 #define XML_SCHEMAS_FACET_UNKNOWN        0
830 /*
831  * XML_SCHEMAS_FACET_PRESERVE:
832  *
833  * preserve the type of the facet
834  */
835 #define XML_SCHEMAS_FACET_PRESERVE        1
836 /*
837  * XML_SCHEMAS_FACET_REPLACE:
838  *
839  * replace the type of the facet
840  */
841 #define XML_SCHEMAS_FACET_REPLACE        2
842 /*
843  * XML_SCHEMAS_FACET_COLLAPSE:
844  *
845  * collapse the types of the facet
846  */
847 #define XML_SCHEMAS_FACET_COLLAPSE        3
848 /**
849  * A facet definition.
850  */
851 struct _xmlSchemaFacet {
852     xmlSchemaTypeType type;        /* The kind of type */
853     struct _xmlSchemaFacet *next;/* the next type if in a sequence ... */
854     const xmlChar *value; /* The original value */
855     const xmlChar *id; /* Obsolete */
856     xmlSchemaAnnotPtr annot;
857     xmlNodePtr node;
858     int fixed; /* XML_SCHEMAS_FACET_PRESERVE, etc. */
859     int whitespace;
860     xmlSchemaValPtr val; /* The compiled value */
861     xmlRegexpPtr    regexp; /* The regex for patterns */
862 };
863 
864 /**
865  * A notation definition.
866  */
867 typedef struct _xmlSchemaNotation xmlSchemaNotation;
868 typedef xmlSchemaNotation *xmlSchemaNotationPtr;
869 struct _xmlSchemaNotation {
870     xmlSchemaTypeType type; /* The kind of type */
871     const xmlChar *name;
872     xmlSchemaAnnotPtr annot;
873     const xmlChar *identifier;
874     const xmlChar *targetNamespace;
875 };
876 
877 /*
878 * TODO: Actually all those flags used for the schema should sit
879 * on the schema parser context, since they are used only
880 * during parsing an XML schema document, and not available
881 * on the component level as per spec.
882 */
883 /**
884  * XML_SCHEMAS_QUALIF_ELEM:
885  *
886  * Reflects elementFormDefault == qualified in
887  * an XML schema document.
888  */
889 #define XML_SCHEMAS_QUALIF_ELEM                1 << 0
890 /**
891  * XML_SCHEMAS_QUALIF_ATTR:
892  *
893  * Reflects attributeFormDefault == qualified in
894  * an XML schema document.
895  */
896 #define XML_SCHEMAS_QUALIF_ATTR            1 << 1
897 /**
898  * XML_SCHEMAS_FINAL_DEFAULT_EXTENSION:
899  *
900  * the schema has "extension" in the set of finalDefault.
901  */
902 #define XML_SCHEMAS_FINAL_DEFAULT_EXTENSION        1 << 2
903 /**
904  * XML_SCHEMAS_FINAL_DEFAULT_RESTRICTION:
905  *
906  * the schema has "restriction" in the set of finalDefault.
907  */
908 #define XML_SCHEMAS_FINAL_DEFAULT_RESTRICTION            1 << 3
909 /**
910  * XML_SCHEMAS_FINAL_DEFAULT_LIST:
911  *
912  * the cshema has "list" in the set of finalDefault.
913  */
914 #define XML_SCHEMAS_FINAL_DEFAULT_LIST            1 << 4
915 /**
916  * XML_SCHEMAS_FINAL_DEFAULT_UNION:
917  *
918  * the schema has "union" in the set of finalDefault.
919  */
920 #define XML_SCHEMAS_FINAL_DEFAULT_UNION            1 << 5
921 /**
922  * XML_SCHEMAS_BLOCK_DEFAULT_EXTENSION:
923  *
924  * the schema has "extension" in the set of blockDefault.
925  */
926 #define XML_SCHEMAS_BLOCK_DEFAULT_EXTENSION            1 << 6
927 /**
928  * XML_SCHEMAS_BLOCK_DEFAULT_RESTRICTION:
929  *
930  * the schema has "restriction" in the set of blockDefault.
931  */
932 #define XML_SCHEMAS_BLOCK_DEFAULT_RESTRICTION            1 << 7
933 /**
934  * XML_SCHEMAS_BLOCK_DEFAULT_SUBSTITUTION:
935  *
936  * the schema has "substitution" in the set of blockDefault.
937  */
938 #define XML_SCHEMAS_BLOCK_DEFAULT_SUBSTITUTION            1 << 8
939 /**
940  * XML_SCHEMAS_INCLUDING_CONVERT_NS:
941  *
942  * the schema is currently including an other schema with
943  * no target namespace.
944  */
945 #define XML_SCHEMAS_INCLUDING_CONVERT_NS            1 << 9
946 /**
947  * _xmlSchema:
948  *
949  * A Schemas definition
950  */
951 struct _xmlSchema {
952     const xmlChar *name; /* schema name */
953     const xmlChar *targetNamespace; /* the target namespace */
954     const xmlChar *version;
955     const xmlChar *id; /* Obsolete */
956     xmlDocPtr doc;
957     xmlSchemaAnnotPtr annot;
958     int flags;
959 
960     xmlHashTablePtr typeDecl;
961     xmlHashTablePtr attrDecl;
962     xmlHashTablePtr attrgrpDecl;
963     xmlHashTablePtr elemDecl;
964     xmlHashTablePtr notaDecl;
965 
966     xmlHashTablePtr schemasImports;
967 
968     void *_private;        /* unused by the library for users or bindings */
969     xmlHashTablePtr groupDecl;
970     xmlDictPtr      dict;
971     void *includes;     /* the includes, this is opaque for now */
972     int preserve;        /* whether to free the document */
973     int counter; /* used to give ononymous components unique names */
974     xmlHashTablePtr idcDef; /* All identity-constraint defs. */
975     void *volatiles; /* Obsolete */
976 };
977 
978 XMLPUBFUN void XMLCALL         xmlSchemaFreeType        (xmlSchemaTypePtr type);
979 XMLPUBFUN void XMLCALL         xmlSchemaFreeWildcard(xmlSchemaWildcardPtr wildcard);
980 
981 #ifdef __cplusplus
982 }
983 #endif
984 
985 #endif /* LIBXML_SCHEMAS_ENABLED */
986 #endif /* __XML_SCHEMA_INTERNALS_H__ */
987