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, |
| 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; |
| 120 | }; |
| 121 | |
| 122 | /** |
| 123 | * An attribute group definition. |
| 124 | * |
| 125 | * xmlSchemaAttribute and xmlSchemaAttributeGroup start of structures |
| 126 | * must be kept similar |
| 127 | */ |
| 128 | typedef struct _xmlSchemaAttributeGroup xmlSchemaAttributeGroup; |
| 129 | typedef xmlSchemaAttributeGroup *xmlSchemaAttributeGroupPtr; |
| 130 | struct _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 | |
| 148 | struct _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 | |
| 184 | typedef struct _xmlSchemaElement xmlSchemaElement; |
| 185 | typedef xmlSchemaElement *xmlSchemaElementPtr; |
| 186 | struct _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 Veillard | 88c5891 | 2002-04-23 07:12:20 +0000 | [diff] [blame^] | 210 | xmlSchemaContentType contentType; |
Daniel Veillard | 4255d50 | 2002-04-16 15:50:10 +0000 | [diff] [blame] | 211 | }; |
| 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 | |
| 222 | struct _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 | */ |
| 238 | typedef struct _xmlSchemaNotation xmlSchemaNotation; |
| 239 | typedef xmlSchemaNotation *xmlSchemaNotationPtr; |
| 240 | struct _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 |
| 252 | struct _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 | |
| 268 | void xmlSchemaFreeType (xmlSchemaTypePtr type); |
| 269 | |
| 270 | #ifdef __cplusplus |
| 271 | } |
| 272 | #endif |
| 273 | |
| 274 | #endif /* LIBXML_SCHEMAS_ENABLED */ |
| 275 | #endif /* __XML_SCHEMA_INTERNALS_H__ */ |
| 276 | |
| 277 | |