Daniel Veillard | 4255d50 | 2002-04-16 15:50:10 +0000 | [diff] [blame] | 1 | /* |
Daniel Veillard | be58697 | 2003-11-18 20:56:51 +0000 | [diff] [blame^] | 2 | * Summary: internal interfaces for XML Schemas |
| 3 | * Description: internal interfaces for the XML Schemas handling |
| 4 | * and schema validity checking |
Daniel Veillard | 4255d50 | 2002-04-16 15:50:10 +0000 | [diff] [blame] | 5 | * |
Daniel Veillard | be58697 | 2003-11-18 20:56:51 +0000 | [diff] [blame^] | 6 | * Copy: See Copyright for the status of this software. |
Daniel Veillard | 4255d50 | 2002-04-16 15:50:10 +0000 | [diff] [blame] | 7 | * |
Daniel Veillard | be58697 | 2003-11-18 20:56:51 +0000 | [diff] [blame^] | 8 | * Author: Daniel Veillard |
Daniel Veillard | 4255d50 | 2002-04-16 15:50:10 +0000 | [diff] [blame] | 9 | */ |
| 10 | |
| 11 | |
| 12 | #ifndef __XML_SCHEMA_INTERNALS_H__ |
| 13 | #define __XML_SCHEMA_INTERNALS_H__ |
| 14 | |
Daniel Veillard | 4255d50 | 2002-04-16 15:50:10 +0000 | [diff] [blame] | 15 | #include <libxml/xmlversion.h> |
Igor Zlatkovic | 7ae91bc | 2002-11-08 17:18:52 +0000 | [diff] [blame] | 16 | |
Daniel Veillard | 4255d50 | 2002-04-16 15:50:10 +0000 | [diff] [blame] | 17 | #ifdef LIBXML_SCHEMAS_ENABLED |
| 18 | |
| 19 | #include <libxml/xmlregexp.h> |
Daniel Veillard | 8326e73 | 2003-01-07 00:19:07 +0000 | [diff] [blame] | 20 | #include <libxml/hash.h> |
Daniel Veillard | 4255d50 | 2002-04-16 15:50:10 +0000 | [diff] [blame] | 21 | |
| 22 | #ifdef __cplusplus |
| 23 | extern "C" { |
| 24 | #endif |
| 25 | |
| 26 | |
| 27 | /* |
| 28 | * XML Schemas defines multiple type of types. |
| 29 | */ |
| 30 | typedef 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 Veillard | 13e04c6 | 2002-04-23 17:51:29 +0000 | [diff] [blame] | 46 | XML_SCHEMA_TYPE_ATTRIBUTEGROUP, |
Daniel Veillard | 4255d50 | 2002-04-16 15:50:10 +0000 | [diff] [blame] | 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 | |
| 65 | typedef 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 Veillard | 88c5891 | 2002-04-23 07:12:20 +0000 | [diff] [blame] | 72 | XML_SCHEMA_CONTENT_BASIC, |
| 73 | XML_SCHEMA_CONTENT_ANY |
Daniel Veillard | 4255d50 | 2002-04-16 15:50:10 +0000 | [diff] [blame] | 74 | } xmlSchemaContentType; |
| 75 | |
| 76 | typedef struct _xmlSchemaVal xmlSchemaVal; |
| 77 | typedef xmlSchemaVal *xmlSchemaValPtr; |
| 78 | |
| 79 | typedef struct _xmlSchemaType xmlSchemaType; |
| 80 | typedef xmlSchemaType *xmlSchemaTypePtr; |
| 81 | |
| 82 | typedef struct _xmlSchemaFacet xmlSchemaFacet; |
| 83 | typedef xmlSchemaFacet *xmlSchemaFacetPtr; |
| 84 | |
| 85 | /** |
| 86 | * Annotation |
| 87 | */ |
| 88 | typedef struct _xmlSchemaAnnot xmlSchemaAnnot; |
| 89 | typedef xmlSchemaAnnot *xmlSchemaAnnotPtr; |
| 90 | struct _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 | |
| 103 | typedef struct _xmlSchemaAttribute xmlSchemaAttribute; |
| 104 | typedef xmlSchemaAttribute *xmlSchemaAttributePtr; |
| 105 | struct _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 Veillard | 75bb3bb | 2003-05-12 15:25:56 +0000 | [diff] [blame] | 120 | xmlNodePtr node; |
Daniel Veillard | 4255d50 | 2002-04-16 15:50:10 +0000 | [diff] [blame] | 121 | }; |
| 122 | |
| 123 | /** |
| 124 | * An attribute group definition. |
| 125 | * |
| 126 | * xmlSchemaAttribute and xmlSchemaAttributeGroup start of structures |
| 127 | * must be kept similar |
| 128 | */ |
| 129 | typedef struct _xmlSchemaAttributeGroup xmlSchemaAttributeGroup; |
| 130 | typedef xmlSchemaAttributeGroup *xmlSchemaAttributeGroupPtr; |
| 131 | struct _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 Veillard | 75bb3bb | 2003-05-12 15:25:56 +0000 | [diff] [blame] | 141 | xmlNodePtr node; |
Daniel Veillard | 4255d50 | 2002-04-16 15:50:10 +0000 | [diff] [blame] | 142 | }; |
| 143 | |
| 144 | |
| 145 | /** |
Daniel Veillard | a9b66d0 | 2002-12-11 14:23:49 +0000 | [diff] [blame] | 146 | * XML_SCHEMAS_TYPE_MIXED: |
| 147 | * |
| 148 | * the element content type is mixed |
Daniel Veillard | 4255d50 | 2002-04-16 15:50:10 +0000 | [diff] [blame] | 149 | */ |
| 150 | #define XML_SCHEMAS_TYPE_MIXED 1 << 0 |
| 151 | |
Daniel Veillard | a9b66d0 | 2002-12-11 14:23:49 +0000 | [diff] [blame] | 152 | /** |
| 153 | * _xmlSchemaType: |
| 154 | * |
| 155 | * Schemas type definition. |
| 156 | */ |
Daniel Veillard | 4255d50 | 2002-04-16 15:50:10 +0000 | [diff] [blame] | 157 | struct _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. Brack | 60f394e | 2003-11-16 06:25:42 +0000 | [diff] [blame] | 179 | /* |
Daniel Veillard | a9b66d0 | 2002-12-11 14:23:49 +0000 | [diff] [blame] | 180 | * xmlSchemaElement: |
Daniel Veillard | 4255d50 | 2002-04-16 15:50:10 +0000 | [diff] [blame] | 181 | * An element definition. |
| 182 | * |
| 183 | * xmlSchemaType, xmlSchemaFacet and xmlSchemaElement start of |
| 184 | * structures must be kept similar |
| 185 | */ |
Daniel Veillard | a9b66d0 | 2002-12-11 14:23:49 +0000 | [diff] [blame] | 186 | /** |
| 187 | * XML_SCHEMAS_ELEM_NILLABLE: |
| 188 | * |
| 189 | * the element is nillable |
| 190 | */ |
Daniel Veillard | 4255d50 | 2002-04-16 15:50:10 +0000 | [diff] [blame] | 191 | #define XML_SCHEMAS_ELEM_NILLABLE 1 << 0 |
Daniel Veillard | a9b66d0 | 2002-12-11 14:23:49 +0000 | [diff] [blame] | 192 | /** |
| 193 | * XML_SCHEMAS_ELEM_GLOBAL: |
| 194 | * |
| 195 | * the element is global |
| 196 | */ |
Daniel Veillard | 4255d50 | 2002-04-16 15:50:10 +0000 | [diff] [blame] | 197 | #define XML_SCHEMAS_ELEM_GLOBAL 1 << 1 |
Daniel Veillard | a9b66d0 | 2002-12-11 14:23:49 +0000 | [diff] [blame] | 198 | /** |
| 199 | * XML_SCHEMAS_ELEM_DEFAULT: |
| 200 | * |
| 201 | * the element has a default value |
| 202 | */ |
Daniel Veillard | 4255d50 | 2002-04-16 15:50:10 +0000 | [diff] [blame] | 203 | #define XML_SCHEMAS_ELEM_DEFAULT 1 << 2 |
Daniel Veillard | a9b66d0 | 2002-12-11 14:23:49 +0000 | [diff] [blame] | 204 | /** |
| 205 | * XML_SCHEMAS_ELEM_FIXED: |
| 206 | * |
| 207 | * the element has a fixed value |
| 208 | */ |
Daniel Veillard | 4255d50 | 2002-04-16 15:50:10 +0000 | [diff] [blame] | 209 | #define XML_SCHEMAS_ELEM_FIXED 1 << 3 |
Daniel Veillard | a9b66d0 | 2002-12-11 14:23:49 +0000 | [diff] [blame] | 210 | /** |
| 211 | * XML_SCHEMAS_ELEM_ABSTRACT: |
| 212 | * |
| 213 | * the element is abstract |
| 214 | */ |
Daniel Veillard | 4255d50 | 2002-04-16 15:50:10 +0000 | [diff] [blame] | 215 | #define XML_SCHEMAS_ELEM_ABSTRACT 1 << 4 |
Daniel Veillard | a9b66d0 | 2002-12-11 14:23:49 +0000 | [diff] [blame] | 216 | /** |
| 217 | * XML_SCHEMAS_ELEM_TOPLEVEL: |
| 218 | * |
| 219 | * the element is top level |
| 220 | */ |
Daniel Veillard | 4255d50 | 2002-04-16 15:50:10 +0000 | [diff] [blame] | 221 | #define XML_SCHEMAS_ELEM_TOPLEVEL 1 << 5 |
Daniel Veillard | a9b66d0 | 2002-12-11 14:23:49 +0000 | [diff] [blame] | 222 | /** |
| 223 | * XML_SCHEMAS_ELEM_REF: |
| 224 | * |
| 225 | * the element is a reference to a type |
| 226 | */ |
Daniel Veillard | 4255d50 | 2002-04-16 15:50:10 +0000 | [diff] [blame] | 227 | #define XML_SCHEMAS_ELEM_REF 1 << 6 |
| 228 | |
| 229 | typedef struct _xmlSchemaElement xmlSchemaElement; |
| 230 | typedef xmlSchemaElement *xmlSchemaElementPtr; |
| 231 | struct _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 Veillard | 88c5891 | 2002-04-23 07:12:20 +0000 | [diff] [blame] | 255 | xmlSchemaContentType contentType; |
Daniel Veillard | 4255d50 | 2002-04-16 15:50:10 +0000 | [diff] [blame] | 256 | }; |
| 257 | |
Daniel Veillard | a9b66d0 | 2002-12-11 14:23:49 +0000 | [diff] [blame] | 258 | /* |
| 259 | * XML_SCHEMAS_FACET_UNKNOWN: |
Daniel Veillard | 4255d50 | 2002-04-16 15:50:10 +0000 | [diff] [blame] | 260 | * |
Daniel Veillard | a9b66d0 | 2002-12-11 14:23:49 +0000 | [diff] [blame] | 261 | * unknown facet handling |
Daniel Veillard | 4255d50 | 2002-04-16 15:50:10 +0000 | [diff] [blame] | 262 | */ |
| 263 | #define XML_SCHEMAS_FACET_UNKNOWN 0 |
Daniel Veillard | a9b66d0 | 2002-12-11 14:23:49 +0000 | [diff] [blame] | 264 | /* |
| 265 | * XML_SCHEMAS_FACET_PRESERVE: |
| 266 | * |
| 267 | * preserve the type of the facet |
| 268 | */ |
Daniel Veillard | 4255d50 | 2002-04-16 15:50:10 +0000 | [diff] [blame] | 269 | #define XML_SCHEMAS_FACET_PRESERVE 1 |
Daniel Veillard | a9b66d0 | 2002-12-11 14:23:49 +0000 | [diff] [blame] | 270 | /* |
| 271 | * XML_SCHEMAS_FACET_REPLACE: |
| 272 | * |
| 273 | * replace the type of the facet |
| 274 | */ |
Daniel Veillard | 4255d50 | 2002-04-16 15:50:10 +0000 | [diff] [blame] | 275 | #define XML_SCHEMAS_FACET_REPLACE 2 |
Daniel Veillard | a9b66d0 | 2002-12-11 14:23:49 +0000 | [diff] [blame] | 276 | /* |
| 277 | * XML_SCHEMAS_FACET_COLLAPSE: |
| 278 | * |
| 279 | * collapse the types of the facet |
| 280 | */ |
Daniel Veillard | 4255d50 | 2002-04-16 15:50:10 +0000 | [diff] [blame] | 281 | #define XML_SCHEMAS_FACET_COLLAPSE 3 |
| 282 | |
Daniel Veillard | a9b66d0 | 2002-12-11 14:23:49 +0000 | [diff] [blame] | 283 | /** |
| 284 | * A facet definition. |
| 285 | */ |
Daniel Veillard | 4255d50 | 2002-04-16 15:50:10 +0000 | [diff] [blame] | 286 | struct _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 | */ |
| 302 | typedef struct _xmlSchemaNotation xmlSchemaNotation; |
| 303 | typedef xmlSchemaNotation *xmlSchemaNotationPtr; |
| 304 | struct _xmlSchemaNotation { |
| 305 | xmlSchemaTypeType type; /* The kind of type */ |
| 306 | xmlChar *name; |
| 307 | xmlSchemaAnnotPtr annot; |
| 308 | xmlChar *identifier; |
| 309 | }; |
| 310 | |
| 311 | /** |
Daniel Veillard | a9b66d0 | 2002-12-11 14:23:49 +0000 | [diff] [blame] | 312 | * XML_SCHEMAS_QUALIF_ELEM: |
| 313 | * |
| 314 | * the shemas requires qualified elements |
Daniel Veillard | 4255d50 | 2002-04-16 15:50:10 +0000 | [diff] [blame] | 315 | */ |
| 316 | #define XML_SCHEMAS_QUALIF_ELEM 1 << 0 |
Daniel Veillard | a9b66d0 | 2002-12-11 14:23:49 +0000 | [diff] [blame] | 317 | /** |
| 318 | * XML_SCHEMAS_QUALIF_ATTR: |
| 319 | * |
| 320 | * the shemas requires qualified attributes |
| 321 | */ |
Daniel Veillard | 4255d50 | 2002-04-16 15:50:10 +0000 | [diff] [blame] | 322 | #define XML_SCHEMAS_QUALIF_ATTR 1 << 1 |
Daniel Veillard | a9b66d0 | 2002-12-11 14:23:49 +0000 | [diff] [blame] | 323 | /** |
| 324 | * _xmlSchema: |
| 325 | * |
| 326 | * A Schemas definition |
| 327 | */ |
Daniel Veillard | 4255d50 | 2002-04-16 15:50:10 +0000 | [diff] [blame] | 328 | struct _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 Veillard | 10b6da4 | 2002-05-18 07:55:20 +0000 | [diff] [blame] | 342 | |
| 343 | xmlHashTablePtr schemasImports; |
Daniel Veillard | 5f7f991 | 2002-06-17 17:03:00 +0000 | [diff] [blame] | 344 | |
| 345 | void *_private; /* unused by the library for users or bindings */ |
Daniel Veillard | a84c0b3 | 2003-06-02 16:58:46 +0000 | [diff] [blame] | 346 | xmlHashTablePtr groupDecl; |
Daniel Veillard | 4255d50 | 2002-04-16 15:50:10 +0000 | [diff] [blame] | 347 | }; |
| 348 | |
Igor Zlatkovic | 76874e4 | 2003-08-25 09:05:12 +0000 | [diff] [blame] | 349 | XMLPUBFUN void XMLCALL xmlSchemaFreeType (xmlSchemaTypePtr type); |
Daniel Veillard | 4255d50 | 2002-04-16 15:50:10 +0000 | [diff] [blame] | 350 | |
| 351 | #ifdef __cplusplus |
| 352 | } |
| 353 | #endif |
| 354 | |
| 355 | #endif /* LIBXML_SCHEMAS_ENABLED */ |
| 356 | #endif /* __XML_SCHEMA_INTERNALS_H__ */ |
| 357 | |
| 358 | |