Daniel Veillard | 4255d50 | 2002-04-16 15:50:10 +0000 | [diff] [blame] | 1 | /* |
| 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 |
| 24 | extern "C" { |
| 25 | #endif |
| 26 | |
| 27 | |
| 28 | /* |
| 29 | * XML Schemas defines multiple type of types. |
| 30 | */ |
| 31 | typedef 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, |
Daniel Veillard | 13e04c6 | 2002-04-23 17:51:29 +0000 | [diff] [blame] | 47 | XML_SCHEMA_TYPE_ATTRIBUTEGROUP, |
Daniel Veillard | 4255d50 | 2002-04-16 15:50:10 +0000 | [diff] [blame] | 48 | XML_SCHEMA_TYPE_GROUP, |
| 49 | XML_SCHEMA_TYPE_NOTATION, |
| 50 | XML_SCHEMA_TYPE_LIST, |
| 51 | XML_SCHEMA_TYPE_UNION, |
| 52 | XML_SCHEMA_FACET_MININCLUSIVE = 1000, |
| 53 | XML_SCHEMA_FACET_MINEXCLUSIVE, |
| 54 | XML_SCHEMA_FACET_MAXINCLUSIVE, |
| 55 | XML_SCHEMA_FACET_MAXEXCLUSIVE, |
| 56 | XML_SCHEMA_FACET_TOTALDIGITS, |
| 57 | XML_SCHEMA_FACET_FRACTIONDIGITS, |
| 58 | XML_SCHEMA_FACET_PATTERN, |
| 59 | XML_SCHEMA_FACET_ENUMERATION, |
| 60 | XML_SCHEMA_FACET_WHITESPACE, |
| 61 | XML_SCHEMA_FACET_LENGTH, |
| 62 | XML_SCHEMA_FACET_MAXLENGTH, |
| 63 | XML_SCHEMA_FACET_MINLENGTH |
| 64 | } xmlSchemaTypeType; |
| 65 | |
| 66 | typedef enum { |
| 67 | XML_SCHEMA_CONTENT_UNKNOWN = 0, |
| 68 | XML_SCHEMA_CONTENT_EMPTY = 1, |
| 69 | XML_SCHEMA_CONTENT_ELEMENTS, |
| 70 | XML_SCHEMA_CONTENT_MIXED, |
| 71 | XML_SCHEMA_CONTENT_SIMPLE, |
| 72 | XML_SCHEMA_CONTENT_MIXED_OR_ELEMENTS, |
Daniel Veillard | 88c5891 | 2002-04-23 07:12:20 +0000 | [diff] [blame] | 73 | XML_SCHEMA_CONTENT_BASIC, |
| 74 | XML_SCHEMA_CONTENT_ANY |
Daniel Veillard | 4255d50 | 2002-04-16 15:50:10 +0000 | [diff] [blame] | 75 | } xmlSchemaContentType; |
| 76 | |
| 77 | typedef struct _xmlSchemaVal xmlSchemaVal; |
| 78 | typedef xmlSchemaVal *xmlSchemaValPtr; |
| 79 | |
| 80 | typedef struct _xmlSchemaType xmlSchemaType; |
| 81 | typedef xmlSchemaType *xmlSchemaTypePtr; |
| 82 | |
| 83 | typedef struct _xmlSchemaFacet xmlSchemaFacet; |
| 84 | typedef xmlSchemaFacet *xmlSchemaFacetPtr; |
| 85 | |
| 86 | /** |
| 87 | * Annotation |
| 88 | */ |
| 89 | typedef struct _xmlSchemaAnnot xmlSchemaAnnot; |
| 90 | typedef xmlSchemaAnnot *xmlSchemaAnnotPtr; |
| 91 | struct _xmlSchemaAnnot { |
| 92 | struct _xmlSchemaAnnot *next; |
| 93 | xmlNodePtr content; /* the annotation */ |
| 94 | }; |
| 95 | |
| 96 | /** |
| 97 | * An attribute definition. |
| 98 | */ |
| 99 | |
| 100 | #define XML_SCHEMAS_ANYATTR_SKIP 1 |
| 101 | #define XML_SCHEMAS_ANYATTR_LAX 2 |
| 102 | #define XML_SCHEMAS_ANYATTR_STRICT 3 |
| 103 | |
| 104 | typedef struct _xmlSchemaAttribute xmlSchemaAttribute; |
| 105 | typedef xmlSchemaAttribute *xmlSchemaAttributePtr; |
| 106 | struct _xmlSchemaAttribute { |
| 107 | xmlSchemaTypeType type; /* The kind of type */ |
| 108 | struct _xmlSchemaAttribute *next;/* the next attribute if in a group ... */ |
| 109 | xmlChar *name; |
| 110 | xmlChar *id; |
| 111 | xmlChar *ref; |
| 112 | xmlChar *refNs; |
| 113 | xmlChar *typeName; |
| 114 | xmlChar *typeNs; |
| 115 | xmlSchemaAnnotPtr annot; |
| 116 | |
| 117 | xmlSchemaTypePtr base; |
| 118 | int occurs; |
| 119 | xmlChar *defValue; |
| 120 | xmlSchemaTypePtr subtypes; |
| 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; |
| 141 | }; |
| 142 | |
| 143 | |
| 144 | /** |
| 145 | * Schemas type definition. |
| 146 | */ |
| 147 | #define XML_SCHEMAS_TYPE_MIXED 1 << 0 |
| 148 | |
| 149 | struct _xmlSchemaType { |
| 150 | xmlSchemaTypeType type; /* The kind of type */ |
| 151 | struct _xmlSchemaType *next;/* the next type if in a sequence ... */ |
| 152 | xmlChar *name; |
| 153 | xmlChar *id; |
| 154 | xmlChar *ref; |
| 155 | xmlChar *refNs; |
| 156 | xmlSchemaAnnotPtr annot; |
| 157 | xmlSchemaTypePtr subtypes; |
| 158 | xmlSchemaAttributePtr attributes; |
| 159 | xmlNodePtr node; |
| 160 | int minOccurs; |
| 161 | int maxOccurs; |
| 162 | |
| 163 | int flags; |
| 164 | xmlSchemaContentType contentType; |
| 165 | xmlChar *base; |
| 166 | xmlChar *baseNs; |
| 167 | xmlSchemaTypePtr baseType; |
| 168 | xmlSchemaFacetPtr facets; |
| 169 | }; |
| 170 | |
| 171 | /** |
| 172 | * An element definition. |
| 173 | * |
| 174 | * xmlSchemaType, xmlSchemaFacet and xmlSchemaElement start of |
| 175 | * structures must be kept similar |
| 176 | */ |
| 177 | #define XML_SCHEMAS_ELEM_NILLABLE 1 << 0 |
| 178 | #define XML_SCHEMAS_ELEM_GLOBAL 1 << 1 |
| 179 | #define XML_SCHEMAS_ELEM_DEFAULT 1 << 2 |
| 180 | #define XML_SCHEMAS_ELEM_FIXED 1 << 3 |
| 181 | #define XML_SCHEMAS_ELEM_ABSTRACT 1 << 4 |
| 182 | #define XML_SCHEMAS_ELEM_TOPLEVEL 1 << 5 |
| 183 | #define XML_SCHEMAS_ELEM_REF 1 << 6 |
| 184 | |
| 185 | typedef struct _xmlSchemaElement xmlSchemaElement; |
| 186 | typedef xmlSchemaElement *xmlSchemaElementPtr; |
| 187 | struct _xmlSchemaElement { |
| 188 | xmlSchemaTypeType type; /* The kind of type */ |
| 189 | struct _xmlSchemaType *next;/* the next type if in a sequence ... */ |
| 190 | xmlChar *name; |
| 191 | xmlChar *id; |
| 192 | xmlChar *ref; |
| 193 | xmlChar *refNs; |
| 194 | xmlSchemaAnnotPtr annot; |
| 195 | xmlSchemaTypePtr subtypes; |
| 196 | xmlSchemaAttributePtr attributes; |
| 197 | xmlNodePtr node; |
| 198 | int minOccurs; |
| 199 | int maxOccurs; |
| 200 | |
| 201 | int flags; |
| 202 | xmlChar *targetNamespace; |
| 203 | xmlChar *namedType; |
| 204 | xmlChar *namedTypeNs; |
| 205 | xmlChar *substGroup; |
| 206 | xmlChar *substGroupNs; |
| 207 | xmlChar *scope; |
| 208 | xmlChar *value; |
| 209 | struct _xmlSchemaElement *refDecl; |
| 210 | xmlRegexpPtr contModel; |
Daniel Veillard | 88c5891 | 2002-04-23 07:12:20 +0000 | [diff] [blame] | 211 | xmlSchemaContentType contentType; |
Daniel Veillard | 4255d50 | 2002-04-16 15:50:10 +0000 | [diff] [blame] | 212 | }; |
| 213 | |
| 214 | /** |
| 215 | * An facet definition. |
| 216 | * |
| 217 | */ |
| 218 | #define XML_SCHEMAS_FACET_UNKNOWN 0 |
| 219 | #define XML_SCHEMAS_FACET_PRESERVE 1 |
| 220 | #define XML_SCHEMAS_FACET_REPLACE 2 |
| 221 | #define XML_SCHEMAS_FACET_COLLAPSE 3 |
| 222 | |
| 223 | struct _xmlSchemaFacet { |
| 224 | xmlSchemaTypeType type; /* The kind of type */ |
| 225 | struct _xmlSchemaFacet *next;/* the next type if in a sequence ... */ |
| 226 | xmlChar *value; |
| 227 | xmlChar *id; |
| 228 | xmlSchemaAnnotPtr annot; |
| 229 | xmlNodePtr node; |
| 230 | int fixed; |
| 231 | int whitespace; |
| 232 | xmlSchemaValPtr val; |
| 233 | xmlRegexpPtr regexp; |
| 234 | }; |
| 235 | |
| 236 | /** |
| 237 | * A notation definition. |
| 238 | */ |
| 239 | typedef struct _xmlSchemaNotation xmlSchemaNotation; |
| 240 | typedef xmlSchemaNotation *xmlSchemaNotationPtr; |
| 241 | struct _xmlSchemaNotation { |
| 242 | xmlSchemaTypeType type; /* The kind of type */ |
| 243 | xmlChar *name; |
| 244 | xmlSchemaAnnotPtr annot; |
| 245 | xmlChar *identifier; |
| 246 | }; |
| 247 | |
| 248 | /** |
| 249 | * A Schemas definition |
| 250 | */ |
| 251 | #define XML_SCHEMAS_QUALIF_ELEM 1 << 0 |
| 252 | #define XML_SCHEMAS_QUALIF_ATTR 1 << 1 |
| 253 | struct _xmlSchema { |
| 254 | xmlChar *name; /* schema name */ |
| 255 | xmlChar *targetNamespace; /* the target namespace */ |
| 256 | xmlChar *version; |
| 257 | xmlChar *id; |
| 258 | xmlDocPtr doc; |
| 259 | xmlSchemaAnnotPtr annot; |
| 260 | int flags; |
| 261 | |
| 262 | xmlHashTablePtr typeDecl; |
| 263 | xmlHashTablePtr attrDecl; |
| 264 | xmlHashTablePtr attrgrpDecl; |
| 265 | xmlHashTablePtr elemDecl; |
| 266 | xmlHashTablePtr notaDecl; |
Daniel Veillard | 10b6da4 | 2002-05-18 07:55:20 +0000 | [diff] [blame] | 267 | |
| 268 | xmlHashTablePtr schemasImports; |
Daniel Veillard | 5f7f991 | 2002-06-17 17:03:00 +0000 | [diff] [blame^] | 269 | |
| 270 | void *_private; /* unused by the library for users or bindings */ |
Daniel Veillard | 4255d50 | 2002-04-16 15:50:10 +0000 | [diff] [blame] | 271 | }; |
| 272 | |
| 273 | void xmlSchemaFreeType (xmlSchemaTypePtr type); |
| 274 | |
| 275 | #ifdef __cplusplus |
| 276 | } |
| 277 | #endif |
| 278 | |
| 279 | #endif /* LIBXML_SCHEMAS_ENABLED */ |
| 280 | #endif /* __XML_SCHEMA_INTERNALS_H__ */ |
| 281 | |
| 282 | |