| File: | xmlschemas.c |
| Location: | line 25293, column 5 |
| Description: | Value stored to 'nbUses' is never read |
| 1 | /* |
| 2 | * schemas.c : implementation of the XML Schema handling and |
| 3 | * schema validity checking |
| 4 | * |
| 5 | * See Copyright for the status of this software. |
| 6 | * |
| 7 | * Daniel Veillard <veillard@redhat.com> |
| 8 | */ |
| 9 | |
| 10 | /* |
| 11 | * TODO: |
| 12 | * - when types are redefined in includes, check that all |
| 13 | * types in the redef list are equal |
| 14 | * -> need a type equality operation. |
| 15 | * - if we don't intend to use the schema for schemas, we |
| 16 | * need to validate all schema attributes (ref, type, name) |
| 17 | * against their types. |
| 18 | * - Eliminate item creation for: ?? |
| 19 | * |
| 20 | * URGENT TODO: |
| 21 | * - For xsi-driven schema acquisition, augment the IDCs after every |
| 22 | * acquisition episode (xmlSchemaAugmentIDC). |
| 23 | * |
| 24 | * NOTES: |
| 25 | * - Elimated item creation for: <restriction>, <extension>, |
| 26 | * <simpleContent>, <complexContent>, <list>, <union> |
| 27 | * |
| 28 | * PROBLEMS: |
| 29 | * - http://lists.w3.org/Archives/Public/www-xml-schema-comments/2005JulSep/0337.html |
| 30 | * IDC XPath expression and chameleon includes: the targetNamespace is changed, so |
| 31 | * XPath will have trouble to resolve to this namespace, since not known. |
| 32 | * |
| 33 | * |
| 34 | * CONSTRAINTS: |
| 35 | * |
| 36 | * Schema Component Constraint: |
| 37 | * All Group Limited (cos-all-limited) |
| 38 | * Status: complete |
| 39 | * (1.2) |
| 40 | * In xmlSchemaGroupDefReferenceTermFixup() and |
| 41 | * (2) |
| 42 | * In xmlSchemaParseModelGroup() |
| 43 | * TODO: Actually this should go to component-level checks, |
| 44 | * but is done here due to performance. Move it to an other layer |
| 45 | * is schema construction via an API is implemented. |
| 46 | */ |
| 47 | #define IN_LIBXML |
| 48 | #include "libxml.h" |
| 49 | |
| 50 | #ifdef LIBXML_SCHEMAS_ENABLED |
| 51 | |
| 52 | #include <string.h> |
| 53 | #include <libxml/xmlmemory.h> |
| 54 | #include <libxml/parser.h> |
| 55 | #include <libxml/parserInternals.h> |
| 56 | #include <libxml/hash.h> |
| 57 | #include <libxml/uri.h> |
| 58 | #include <libxml/xmlschemas.h> |
| 59 | #include <libxml/schemasInternals.h> |
| 60 | #include <libxml/xmlschemastypes.h> |
| 61 | #include <libxml/xmlautomata.h> |
| 62 | #include <libxml/xmlregexp.h> |
| 63 | #include <libxml/dict.h> |
| 64 | #include <libxml/encoding.h> |
| 65 | #include <libxml/xmlIO.h> |
| 66 | #ifdef LIBXML_PATTERN_ENABLED |
| 67 | #include <libxml/pattern.h> |
| 68 | #endif |
| 69 | #ifdef LIBXML_READER_ENABLED |
| 70 | #include <libxml/xmlreader.h> |
| 71 | #endif |
| 72 | |
| 73 | /* #define DEBUG 1 */ |
| 74 | |
| 75 | /* #define DEBUG_CONTENT 1 */ |
| 76 | |
| 77 | /* #define DEBUG_TYPE 1 */ |
| 78 | |
| 79 | /* #define DEBUG_CONTENT_REGEXP 1 */ |
| 80 | |
| 81 | /* #define DEBUG_AUTOMATA 1 */ |
| 82 | |
| 83 | /* #define DEBUG_IDC */ |
| 84 | |
| 85 | /* #define DEBUG_IDC_NODE_TABLE */ |
| 86 | |
| 87 | /* #define WXS_ELEM_DECL_CONS_ENABLED */ |
| 88 | |
| 89 | #ifdef DEBUG_IDC |
| 90 | #ifndef DEBUG_IDC_NODE_TABLE |
| 91 | #define DEBUG_IDC_NODE_TABLE |
| 92 | #endif |
| 93 | #endif |
| 94 | |
| 95 | /* #define ENABLE_PARTICLE_RESTRICTION 1 */ |
| 96 | |
| 97 | #define ENABLE_REDEFINE |
| 98 | |
| 99 | /* #define ENABLE_NAMED_LOCALS */ |
| 100 | |
| 101 | /* #define ENABLE_IDC_NODE_TABLES_TEST */ |
| 102 | |
| 103 | #define DUMP_CONTENT_MODEL |
| 104 | |
| 105 | #ifdef LIBXML_READER_ENABLED |
| 106 | /* #define XML_SCHEMA_READER_ENABLED */ |
| 107 | #endif |
| 108 | |
| 109 | #define UNBOUNDED(1 << 30) (1 << 30) |
| 110 | #define TODO(*(__xmlGenericError()))((*(__xmlGenericErrorContext())), "Unimplemented block at %s:%d\n" , "xmlschemas.c", 110); \ |
| 111 | xmlGenericError(*(__xmlGenericError()))(xmlGenericErrorContext(*(__xmlGenericErrorContext())), \ |
| 112 | "Unimplemented block at %s:%d\n", \ |
| 113 | __FILE__"xmlschemas.c", __LINE__113); |
| 114 | |
| 115 | #define XML_SCHEMAS_NO_NAMESPACE(const xmlChar *) "##" (const xmlChar *) "##" |
| 116 | |
| 117 | /* |
| 118 | * The XML Schemas namespaces |
| 119 | */ |
| 120 | static const xmlChar *xmlSchemaNs = (const xmlChar *) |
| 121 | "http://www.w3.org/2001/XMLSchema"; |
| 122 | |
| 123 | static const xmlChar *xmlSchemaInstanceNs = (const xmlChar *) |
| 124 | "http://www.w3.org/2001/XMLSchema-instance"; |
| 125 | |
| 126 | static const xmlChar *xmlNamespaceNs = (const xmlChar *) |
| 127 | "http://www.w3.org/2000/xmlns/"; |
| 128 | |
| 129 | /* |
| 130 | * Come casting macros. |
| 131 | */ |
| 132 | #define ACTXT_CAST(xmlSchemaAbstractCtxtPtr) (xmlSchemaAbstractCtxtPtr) |
| 133 | #define PCTXT_CAST(xmlSchemaParserCtxtPtr) (xmlSchemaParserCtxtPtr) |
| 134 | #define VCTXT_CAST(xmlSchemaValidCtxtPtr) (xmlSchemaValidCtxtPtr) |
| 135 | #define WXS_BASIC_CAST(xmlSchemaBasicItemPtr) (xmlSchemaBasicItemPtr) |
| 136 | #define WXS_TREE_CAST(xmlSchemaTreeItemPtr) (xmlSchemaTreeItemPtr) |
| 137 | #define WXS_PTC_CAST(xmlSchemaParticlePtr) (xmlSchemaParticlePtr) |
| 138 | #define WXS_TYPE_CAST(xmlSchemaTypePtr) (xmlSchemaTypePtr) |
| 139 | #define WXS_ELEM_CAST(xmlSchemaElementPtr) (xmlSchemaElementPtr) |
| 140 | #define WXS_ATTR_GROUP_CAST(xmlSchemaAttributeGroupPtr) (xmlSchemaAttributeGroupPtr) |
| 141 | #define WXS_ATTR_CAST(xmlSchemaAttributePtr) (xmlSchemaAttributePtr) |
| 142 | #define WXS_ATTR_USE_CAST(xmlSchemaAttributeUsePtr) (xmlSchemaAttributeUsePtr) |
| 143 | #define WXS_ATTR_PROHIB_CAST(xmlSchemaAttributeUseProhibPtr) (xmlSchemaAttributeUseProhibPtr) |
| 144 | #define WXS_MODEL_GROUPDEF_CAST(xmlSchemaModelGroupDefPtr) (xmlSchemaModelGroupDefPtr) |
| 145 | #define WXS_MODEL_GROUP_CAST(xmlSchemaModelGroupPtr) (xmlSchemaModelGroupPtr) |
| 146 | #define WXS_IDC_CAST(xmlSchemaIDCPtr) (xmlSchemaIDCPtr) |
| 147 | #define WXS_QNAME_CAST(xmlSchemaQNameRefPtr) (xmlSchemaQNameRefPtr) |
| 148 | #define WXS_LIST_CAST(xmlSchemaItemListPtr) (xmlSchemaItemListPtr) |
| 149 | |
| 150 | /* |
| 151 | * Macros to query common properties of components. |
| 152 | */ |
| 153 | #define WXS_ITEM_NODE(i)xmlSchemaGetComponentNode((xmlSchemaBasicItemPtr) (i)) xmlSchemaGetComponentNode(WXS_BASIC_CAST(xmlSchemaBasicItemPtr) (i)) |
| 154 | |
| 155 | #define WXS_ITEM_TYPE_NAME(i)xmlSchemaGetComponentTypeStr((xmlSchemaBasicItemPtr) (i)) xmlSchemaGetComponentTypeStr(WXS_BASIC_CAST(xmlSchemaBasicItemPtr) (i)) |
| 156 | /* |
| 157 | * Macros for element declarations. |
| 158 | */ |
| 159 | #define WXS_ELEM_TYPEDEF(e)(e)->subtypes (e)->subtypes |
| 160 | |
| 161 | #define WXS_SUBST_HEAD(item)(item)->refDecl (item)->refDecl |
| 162 | /* |
| 163 | * Macros for attribute declarations. |
| 164 | */ |
| 165 | #define WXS_ATTR_TYPEDEF(a)(a)->subtypes (a)->subtypes |
| 166 | /* |
| 167 | * Macros for attribute uses. |
| 168 | */ |
| 169 | #define WXS_ATTRUSE_DECL(au)(xmlSchemaAttributePtr) ((xmlSchemaAttributeUsePtr) (au))-> attrDecl WXS_ATTR_CAST(xmlSchemaAttributePtr) (WXS_ATTR_USE_CAST(xmlSchemaAttributeUsePtr) (au))->attrDecl |
| 170 | |
| 171 | #define WXS_ATTRUSE_TYPEDEF(au)((xmlSchemaAttributePtr) ((xmlSchemaAttributeUsePtr) ((xmlSchemaAttributeUsePtr ) au))->attrDecl)->subtypes WXS_ATTR_TYPEDEF(WXS_ATTRUSE_DECL( WXS_ATTR_USE_CAST au))((xmlSchemaAttributePtr) ((xmlSchemaAttributeUsePtr) ((xmlSchemaAttributeUsePtr ) au))->attrDecl)->subtypes |
| 172 | |
| 173 | #define WXS_ATTRUSE_DECL_NAME(au)((xmlSchemaAttributePtr) ((xmlSchemaAttributeUsePtr) (au))-> attrDecl)->name (WXS_ATTRUSE_DECL(au)(xmlSchemaAttributePtr) ((xmlSchemaAttributeUsePtr) (au))-> attrDecl)->name |
| 174 | |
| 175 | #define WXS_ATTRUSE_DECL_TNS(au)((xmlSchemaAttributePtr) ((xmlSchemaAttributeUsePtr) (au))-> attrDecl)->targetNamespace (WXS_ATTRUSE_DECL(au)(xmlSchemaAttributePtr) ((xmlSchemaAttributeUsePtr) (au))-> attrDecl)->targetNamespace |
| 176 | /* |
| 177 | * Macros for attribute groups. |
| 178 | */ |
| 179 | #define WXS_ATTR_GROUP_HAS_REFS(ag)(((xmlSchemaAttributeGroupPtr) (ag))->flags & 1 << 4) ((WXS_ATTR_GROUP_CAST(xmlSchemaAttributeGroupPtr) (ag))->flags & XML_SCHEMAS_ATTRGROUP_HAS_REFS1 << 4) |
| 180 | #define WXS_ATTR_GROUP_EXPANDED(ag)(((xmlSchemaAttributeGroupPtr) (ag))->flags & 1 << 0) ((WXS_ATTR_GROUP_CAST(xmlSchemaAttributeGroupPtr) (ag))->flags & XML_SCHEMAS_ATTRGROUP_WILDCARD_BUILDED1 << 0) |
| 181 | /* |
| 182 | * Macros for particles. |
| 183 | */ |
| 184 | #define WXS_PARTICLE(p)(xmlSchemaParticlePtr) (p) WXS_PTC_CAST(xmlSchemaParticlePtr) (p) |
| 185 | |
| 186 | #define WXS_PARTICLE_TERM(p)((xmlSchemaParticlePtr) (p))->children (WXS_PARTICLE(p)(xmlSchemaParticlePtr) (p))->children |
| 187 | |
| 188 | #define WXS_PARTICLE_TERM_AS_ELEM(p)((xmlSchemaElementPtr) ((xmlSchemaParticlePtr) (p))->children ) (WXS_ELEM_CAST(xmlSchemaElementPtr) WXS_PARTICLE_TERM(p)((xmlSchemaParticlePtr) (p))->children) |
| 189 | |
| 190 | #define WXS_PARTICLE_MODEL(p)(xmlSchemaModelGroupPtr) (xmlSchemaParticlePtr) (p)->children WXS_MODEL_GROUP_CAST(xmlSchemaModelGroupPtr) WXS_PARTICLE(p)(xmlSchemaParticlePtr) (p)->children |
| 191 | /* |
| 192 | * Macros for model groups definitions. |
| 193 | */ |
| 194 | #define WXS_MODELGROUPDEF_MODEL(mgd)((xmlSchemaModelGroupPtr) (mgd))->children (WXS_MODEL_GROUP_CAST(xmlSchemaModelGroupPtr) (mgd))->children |
| 195 | /* |
| 196 | * Macros for model groups. |
| 197 | */ |
| 198 | #define WXS_IS_MODEL_GROUP(i)(((i)->type == XML_SCHEMA_TYPE_SEQUENCE) || ((i)->type == XML_SCHEMA_TYPE_CHOICE) || ((i)->type == XML_SCHEMA_TYPE_ALL )) \ |
| 199 | (((i)->type == XML_SCHEMA_TYPE_SEQUENCE) || \ |
| 200 | ((i)->type == XML_SCHEMA_TYPE_CHOICE) || \ |
| 201 | ((i)->type == XML_SCHEMA_TYPE_ALL)) |
| 202 | |
| 203 | #define WXS_MODELGROUP_PARTICLE(mg)(xmlSchemaParticlePtr) (mg)->children WXS_PTC_CAST(xmlSchemaParticlePtr) (mg)->children |
| 204 | /* |
| 205 | * Macros for schema buckets. |
| 206 | */ |
| 207 | #define WXS_IS_BUCKET_INCREDEF(t)(((t) == 2) || ((t) == 3)) (((t) == XML_SCHEMA_SCHEMA_INCLUDE2) || \ |
| 208 | ((t) == XML_SCHEMA_SCHEMA_REDEFINE3)) |
| 209 | |
| 210 | #define WXS_IS_BUCKET_IMPMAIN(t)(((t) == 0) || ((t) == 1)) (((t) == XML_SCHEMA_SCHEMA_MAIN0) || \ |
| 211 | ((t) == XML_SCHEMA_SCHEMA_IMPORT1)) |
| 212 | |
| 213 | #define WXS_IMPBUCKET(b)((xmlSchemaImportPtr) (b)) ((xmlSchemaImportPtr) (b)) |
| 214 | |
| 215 | #define WXS_INCBUCKET(b)((xmlSchemaIncludePtr) (b)) ((xmlSchemaIncludePtr) (b)) |
| 216 | /* |
| 217 | * Macros for complex/simple types. |
| 218 | */ |
| 219 | #define WXS_IS_ANYTYPE(i)(( (i)->type == XML_SCHEMA_TYPE_BASIC) && ( ((xmlSchemaTypePtr ) (i))->builtInType == XML_SCHEMAS_ANYTYPE)) \ |
| 220 | (( (i)->type == XML_SCHEMA_TYPE_BASIC) && \ |
| 221 | ( (WXS_TYPE_CAST(xmlSchemaTypePtr) (i))->builtInType == XML_SCHEMAS_ANYTYPE)) |
| 222 | |
| 223 | #define WXS_IS_COMPLEX(i)(((i)->type == XML_SCHEMA_TYPE_COMPLEX) || ((i)->builtInType == XML_SCHEMAS_ANYTYPE)) \ |
| 224 | (((i)->type == XML_SCHEMA_TYPE_COMPLEX) || \ |
| 225 | ((i)->builtInType == XML_SCHEMAS_ANYTYPE)) |
| 226 | |
| 227 | #define WXS_IS_SIMPLE(item)((item->type == XML_SCHEMA_TYPE_SIMPLE) || ((item->type == XML_SCHEMA_TYPE_BASIC) && (item->builtInType != XML_SCHEMAS_ANYTYPE))) \ |
| 228 | ((item->type == XML_SCHEMA_TYPE_SIMPLE) || \ |
| 229 | ((item->type == XML_SCHEMA_TYPE_BASIC) && \ |
| 230 | (item->builtInType != XML_SCHEMAS_ANYTYPE))) |
| 231 | |
| 232 | #define WXS_IS_ANY_SIMPLE_TYPE(i)(((i)->type == XML_SCHEMA_TYPE_BASIC) && ((i)-> builtInType == XML_SCHEMAS_ANYSIMPLETYPE)) \ |
| 233 | (((i)->type == XML_SCHEMA_TYPE_BASIC) && \ |
| 234 | ((i)->builtInType == XML_SCHEMAS_ANYSIMPLETYPE)) |
| 235 | |
| 236 | #define WXS_IS_RESTRICTION(t)((t)->flags & 1 << 2) \ |
| 237 | ((t)->flags & XML_SCHEMAS_TYPE_DERIVATION_METHOD_RESTRICTION1 << 2) |
| 238 | |
| 239 | #define WXS_IS_EXTENSION(t)((t)->flags & 1 << 1) \ |
| 240 | ((t)->flags & XML_SCHEMAS_TYPE_DERIVATION_METHOD_EXTENSION1 << 1) |
| 241 | |
| 242 | #define WXS_IS_TYPE_NOT_FIXED(i)(((i)->type != XML_SCHEMA_TYPE_BASIC) && (((i)-> flags & 1 << 22) == 0)) \ |
| 243 | (((i)->type != XML_SCHEMA_TYPE_BASIC) && \ |
| 244 | (((i)->flags & XML_SCHEMAS_TYPE_INTERNAL_RESOLVED1 << 22) == 0)) |
| 245 | |
| 246 | #define WXS_IS_TYPE_NOT_FIXED_1(item)(((item)->type != XML_SCHEMA_TYPE_BASIC) && (((item )->flags & 1 << 29) == 0)) \ |
| 247 | (((item)->type != XML_SCHEMA_TYPE_BASIC) && \ |
| 248 | (((item)->flags & XML_SCHEMAS_TYPE_FIXUP_11 << 29) == 0)) |
| 249 | |
| 250 | #define WXS_TYPE_IS_GLOBAL(t)((t)->flags & 1 << 3) ((t)->flags & XML_SCHEMAS_TYPE_GLOBAL1 << 3) |
| 251 | |
| 252 | #define WXS_TYPE_IS_LOCAL(t)(((t)->flags & 1 << 3) == 0) (((t)->flags & XML_SCHEMAS_TYPE_GLOBAL1 << 3) == 0) |
| 253 | /* |
| 254 | * Macros for exclusively for complex types. |
| 255 | */ |
| 256 | #define WXS_HAS_COMPLEX_CONTENT(item)((item->contentType == XML_SCHEMA_CONTENT_MIXED) || (item-> contentType == XML_SCHEMA_CONTENT_EMPTY) || (item->contentType == XML_SCHEMA_CONTENT_ELEMENTS)) \ |
| 257 | ((item->contentType == XML_SCHEMA_CONTENT_MIXED) || \ |
| 258 | (item->contentType == XML_SCHEMA_CONTENT_EMPTY) || \ |
| 259 | (item->contentType == XML_SCHEMA_CONTENT_ELEMENTS)) |
| 260 | |
| 261 | #define WXS_HAS_SIMPLE_CONTENT(item)((item->contentType == XML_SCHEMA_CONTENT_SIMPLE) || (item ->contentType == XML_SCHEMA_CONTENT_BASIC)) \ |
| 262 | ((item->contentType == XML_SCHEMA_CONTENT_SIMPLE) || \ |
| 263 | (item->contentType == XML_SCHEMA_CONTENT_BASIC)) |
| 264 | |
| 265 | #define WXS_HAS_MIXED_CONTENT(item)(item->contentType == XML_SCHEMA_CONTENT_MIXED) \ |
| 266 | (item->contentType == XML_SCHEMA_CONTENT_MIXED) |
| 267 | |
| 268 | #define WXS_EMPTIABLE(t)(xmlSchemaIsParticleEmptiable((xmlSchemaParticlePtr) (t)-> subtypes)) \ |
| 269 | (xmlSchemaIsParticleEmptiable(WXS_PTC_CAST(xmlSchemaParticlePtr) (t)->subtypes)) |
| 270 | |
| 271 | #define WXS_TYPE_CONTENTTYPE(t)(t)->subtypes (t)->subtypes |
| 272 | |
| 273 | #define WXS_TYPE_PARTICLE(t)(xmlSchemaParticlePtr) (t)->subtypes WXS_PTC_CAST(xmlSchemaParticlePtr) (t)->subtypes |
| 274 | |
| 275 | #define WXS_TYPE_PARTICLE_TERM(t)((xmlSchemaParticlePtr) ((xmlSchemaParticlePtr) (t)->subtypes ))->children WXS_PARTICLE_TERM(WXS_TYPE_PARTICLE(t))((xmlSchemaParticlePtr) ((xmlSchemaParticlePtr) (t)->subtypes ))->children |
| 276 | /* |
| 277 | * Macros for exclusively for simple types. |
| 278 | */ |
| 279 | #define WXS_LIST_ITEMTYPE(t)(t)->subtypes (t)->subtypes |
| 280 | |
| 281 | #define WXS_IS_ATOMIC(t)(t->flags & 1 << 8) (t->flags & XML_SCHEMAS_TYPE_VARIETY_ATOMIC1 << 8) |
| 282 | |
| 283 | #define WXS_IS_LIST(t)(t->flags & 1 << 6) (t->flags & XML_SCHEMAS_TYPE_VARIETY_LIST1 << 6) |
| 284 | |
| 285 | #define WXS_IS_UNION(t)(t->flags & 1 << 7) (t->flags & XML_SCHEMAS_TYPE_VARIETY_UNION1 << 7) |
| 286 | /* |
| 287 | * Misc parser context macros. |
| 288 | */ |
| 289 | #define WXS_CONSTRUCTOR(ctx)(ctx)->constructor (ctx)->constructor |
| 290 | |
| 291 | #define WXS_HAS_BUCKETS(ctx)( (((ctx))->constructor->buckets != ((void*)0)) && (((ctx))->constructor->buckets->nbItems > 0) ) \ |
| 292 | ( (WXS_CONSTRUCTOR((ctx))((ctx))->constructor->buckets != NULL((void*)0)) && \ |
| 293 | (WXS_CONSTRUCTOR((ctx))((ctx))->constructor->buckets->nbItems > 0) ) |
| 294 | |
| 295 | #define WXS_SUBST_GROUPS(ctx)((ctx))->constructor->substGroups WXS_CONSTRUCTOR((ctx))((ctx))->constructor->substGroups |
| 296 | |
| 297 | #define WXS_BUCKET(ctx)((ctx))->constructor->bucket WXS_CONSTRUCTOR((ctx))((ctx))->constructor->bucket |
| 298 | |
| 299 | #define WXS_SCHEMA(ctx)(ctx)->schema (ctx)->schema |
| 300 | |
| 301 | #define WXS_ADD_LOCAL(ctx, item)xmlSchemaAddItemSize(&(((ctx))->constructor->bucket ->locals), 10, item) \ |
| 302 | xmlSchemaAddItemSize(&(WXS_BUCKET(ctx)((ctx))->constructor->bucket->locals), 10, item) |
| 303 | |
| 304 | #define WXS_ADD_GLOBAL(ctx, item)xmlSchemaAddItemSize(&(((ctx))->constructor->bucket ->globals), 5, item) \ |
| 305 | xmlSchemaAddItemSize(&(WXS_BUCKET(ctx)((ctx))->constructor->bucket->globals), 5, item) |
| 306 | |
| 307 | #define WXS_ADD_PENDING(ctx, item)xmlSchemaAddItemSize(&((ctx)->constructor->pending) , 10, item) \ |
| 308 | xmlSchemaAddItemSize(&((ctx)->constructor->pending), 10, item) |
| 309 | /* |
| 310 | * xmlSchemaItemList macros. |
| 311 | */ |
| 312 | #define WXS_ILIST_IS_EMPTY(l)((l == ((void*)0)) || ((l)->nbItems == 0)) ((l == NULL((void*)0)) || ((l)->nbItems == 0)) |
| 313 | /* |
| 314 | * Misc macros. |
| 315 | */ |
| 316 | #define IS_SCHEMA(node, type)((node != ((void*)0)) && (node->ns != ((void*)0)) && (xmlStrEqual(node->name, (const xmlChar *) type)) && (xmlStrEqual(node->ns->href, xmlSchemaNs))) \ |
| 317 | ((node != NULL((void*)0)) && (node->ns != NULL((void*)0)) && \ |
| 318 | (xmlStrEqual(node->name, (const xmlChar *) type)) && \ |
| 319 | (xmlStrEqual(node->ns->href, xmlSchemaNs))) |
| 320 | |
| 321 | #define FREE_AND_NULL(str)if ((str) != ((void*)0)) { xmlFree((xmlChar *) (str)); str = ( (void*)0); } if ((str) != NULL((void*)0)) { xmlFree((xmlChar *) (str)); str = NULL((void*)0); } |
| 322 | |
| 323 | /* |
| 324 | * Since we put the default/fixed values into the dict, we can |
| 325 | * use pointer comparison for those values. |
| 326 | * REMOVED: (xmlStrEqual((v1), (v2))) |
| 327 | */ |
| 328 | #define WXS_ARE_DEFAULT_STR_EQUAL(v1, v2)((v1) == (v2)) ((v1) == (v2)) |
| 329 | |
| 330 | #define INODE_NILLED(item)(item->flags & 1<<2) (item->flags & XML_SCHEMA_ELEM_INFO_NILLED1<<2) |
| 331 | |
| 332 | #define CAN_PARSE_SCHEMA(b)(((b)->doc != ((void*)0)) && ((b)->parsed == 0) ) (((b)->doc != NULL((void*)0)) && ((b)->parsed == 0)) |
| 333 | |
| 334 | #define HFAILUREif (res == -1) goto exit_failure; if (res == -1) goto exit_failure; |
| 335 | |
| 336 | #define HERRORif (res != 0) goto exit_error; if (res != 0) goto exit_error; |
| 337 | |
| 338 | #define HSTOP(ctx)if ((ctx)->stop) goto exit; if ((ctx)->stop) goto exit; |
| 339 | /* |
| 340 | * Some flags used for various schema constraints. |
| 341 | */ |
| 342 | #define SUBSET_RESTRICTION1<<0 1<<0 |
| 343 | #define SUBSET_EXTENSION1<<1 1<<1 |
| 344 | #define SUBSET_SUBSTITUTION1<<2 1<<2 |
| 345 | #define SUBSET_LIST1<<3 1<<3 |
| 346 | #define SUBSET_UNION1<<4 1<<4 |
| 347 | |
| 348 | typedef struct _xmlSchemaNodeInfo xmlSchemaNodeInfo; |
| 349 | typedef xmlSchemaNodeInfo *xmlSchemaNodeInfoPtr; |
| 350 | |
| 351 | typedef struct _xmlSchemaItemList xmlSchemaItemList; |
| 352 | typedef xmlSchemaItemList *xmlSchemaItemListPtr; |
| 353 | struct _xmlSchemaItemList { |
| 354 | void **items; /* used for dynamic addition of schemata */ |
| 355 | int nbItems; /* used for dynamic addition of schemata */ |
| 356 | int sizeItems; /* used for dynamic addition of schemata */ |
| 357 | }; |
| 358 | |
| 359 | #define XML_SCHEMA_CTXT_PARSER1 1 |
| 360 | #define XML_SCHEMA_CTXT_VALIDATOR2 2 |
| 361 | |
| 362 | typedef struct _xmlSchemaAbstractCtxt xmlSchemaAbstractCtxt; |
| 363 | typedef xmlSchemaAbstractCtxt *xmlSchemaAbstractCtxtPtr; |
| 364 | struct _xmlSchemaAbstractCtxt { |
| 365 | int type; /* E.g. XML_SCHEMA_CTXT_VALIDATOR */ |
| 366 | }; |
| 367 | |
| 368 | typedef struct _xmlSchemaBucket xmlSchemaBucket; |
| 369 | typedef xmlSchemaBucket *xmlSchemaBucketPtr; |
| 370 | |
| 371 | #define XML_SCHEMA_SCHEMA_MAIN0 0 |
| 372 | #define XML_SCHEMA_SCHEMA_IMPORT1 1 |
| 373 | #define XML_SCHEMA_SCHEMA_INCLUDE2 2 |
| 374 | #define XML_SCHEMA_SCHEMA_REDEFINE3 3 |
| 375 | |
| 376 | /** |
| 377 | * xmlSchemaSchemaRelation: |
| 378 | * |
| 379 | * Used to create a graph of schema relationships. |
| 380 | */ |
| 381 | typedef struct _xmlSchemaSchemaRelation xmlSchemaSchemaRelation; |
| 382 | typedef xmlSchemaSchemaRelation *xmlSchemaSchemaRelationPtr; |
| 383 | struct _xmlSchemaSchemaRelation { |
| 384 | xmlSchemaSchemaRelationPtr next; |
| 385 | int type; /* E.g. XML_SCHEMA_SCHEMA_IMPORT */ |
| 386 | const xmlChar *importNamespace; |
| 387 | xmlSchemaBucketPtr bucket; |
| 388 | }; |
| 389 | |
| 390 | #define XML_SCHEMA_BUCKET_MARKED1<<0 1<<0 |
| 391 | #define XML_SCHEMA_BUCKET_COMPS_ADDED1<<1 1<<1 |
| 392 | |
| 393 | struct _xmlSchemaBucket { |
| 394 | int type; |
| 395 | int flags; |
| 396 | const xmlChar *schemaLocation; |
| 397 | const xmlChar *origTargetNamespace; |
| 398 | const xmlChar *targetNamespace; |
| 399 | xmlDocPtr doc; |
| 400 | xmlSchemaSchemaRelationPtr relations; |
| 401 | int located; |
| 402 | int parsed; |
| 403 | int imported; |
| 404 | int preserveDoc; |
| 405 | xmlSchemaItemListPtr globals; /* Global components. */ |
| 406 | xmlSchemaItemListPtr locals; /* Local components. */ |
| 407 | }; |
| 408 | |
| 409 | /** |
| 410 | * xmlSchemaImport: |
| 411 | * (extends xmlSchemaBucket) |
| 412 | * |
| 413 | * Reflects a schema. Holds some information |
| 414 | * about the schema and its toplevel components. Duplicate |
| 415 | * toplevel components are not checked at this level. |
| 416 | */ |
| 417 | typedef struct _xmlSchemaImport xmlSchemaImport; |
| 418 | typedef xmlSchemaImport *xmlSchemaImportPtr; |
| 419 | struct _xmlSchemaImport { |
| 420 | int type; /* Main OR import OR include. */ |
| 421 | int flags; |
| 422 | const xmlChar *schemaLocation; /* The URI of the schema document. */ |
| 423 | /* For chameleon includes, @origTargetNamespace will be NULL */ |
| 424 | const xmlChar *origTargetNamespace; |
| 425 | /* |
| 426 | * For chameleon includes, @targetNamespace will be the |
| 427 | * targetNamespace of the including schema. |
| 428 | */ |
| 429 | const xmlChar *targetNamespace; |
| 430 | xmlDocPtr doc; /* The schema node-tree. */ |
| 431 | /* @relations will hold any included/imported/redefined schemas. */ |
| 432 | xmlSchemaSchemaRelationPtr relations; |
| 433 | int located; |
| 434 | int parsed; |
| 435 | int imported; |
| 436 | int preserveDoc; |
| 437 | xmlSchemaItemListPtr globals; |
| 438 | xmlSchemaItemListPtr locals; |
| 439 | /* The imported schema. */ |
| 440 | xmlSchemaPtr schema; |
| 441 | }; |
| 442 | |
| 443 | /* |
| 444 | * (extends xmlSchemaBucket) |
| 445 | */ |
| 446 | typedef struct _xmlSchemaInclude xmlSchemaInclude; |
| 447 | typedef xmlSchemaInclude *xmlSchemaIncludePtr; |
| 448 | struct _xmlSchemaInclude { |
| 449 | int type; |
| 450 | int flags; |
| 451 | const xmlChar *schemaLocation; |
| 452 | const xmlChar *origTargetNamespace; |
| 453 | const xmlChar *targetNamespace; |
| 454 | xmlDocPtr doc; |
| 455 | xmlSchemaSchemaRelationPtr relations; |
| 456 | int located; |
| 457 | int parsed; |
| 458 | int imported; |
| 459 | int preserveDoc; |
| 460 | xmlSchemaItemListPtr globals; /* Global components. */ |
| 461 | xmlSchemaItemListPtr locals; /* Local components. */ |
| 462 | |
| 463 | /* The owning main or import schema bucket. */ |
| 464 | xmlSchemaImportPtr ownerImport; |
| 465 | }; |
| 466 | |
| 467 | /** |
| 468 | * xmlSchemaBasicItem: |
| 469 | * |
| 470 | * The abstract base type for schema components. |
| 471 | */ |
| 472 | typedef struct _xmlSchemaBasicItem xmlSchemaBasicItem; |
| 473 | typedef xmlSchemaBasicItem *xmlSchemaBasicItemPtr; |
| 474 | struct _xmlSchemaBasicItem { |
| 475 | xmlSchemaTypeType type; |
| 476 | }; |
| 477 | |
| 478 | /** |
| 479 | * xmlSchemaAnnotItem: |
| 480 | * |
| 481 | * The abstract base type for annotated schema components. |
| 482 | * (Extends xmlSchemaBasicItem) |
| 483 | */ |
| 484 | typedef struct _xmlSchemaAnnotItem xmlSchemaAnnotItem; |
| 485 | typedef xmlSchemaAnnotItem *xmlSchemaAnnotItemPtr; |
| 486 | struct _xmlSchemaAnnotItem { |
| 487 | xmlSchemaTypeType type; |
| 488 | xmlSchemaAnnotPtr annot; |
| 489 | }; |
| 490 | |
| 491 | /** |
| 492 | * xmlSchemaTreeItem: |
| 493 | * |
| 494 | * The abstract base type for tree-like structured schema components. |
| 495 | * (Extends xmlSchemaAnnotItem) |
| 496 | */ |
| 497 | typedef struct _xmlSchemaTreeItem xmlSchemaTreeItem; |
| 498 | typedef xmlSchemaTreeItem *xmlSchemaTreeItemPtr; |
| 499 | struct _xmlSchemaTreeItem { |
| 500 | xmlSchemaTypeType type; |
| 501 | xmlSchemaAnnotPtr annot; |
| 502 | xmlSchemaTreeItemPtr next; |
| 503 | xmlSchemaTreeItemPtr children; |
| 504 | }; |
| 505 | |
| 506 | |
| 507 | #define XML_SCHEMA_ATTR_USE_FIXED1<<0 1<<0 |
| 508 | /** |
| 509 | * xmlSchemaAttributeUsePtr: |
| 510 | * |
| 511 | * The abstract base type for tree-like structured schema components. |
| 512 | * (Extends xmlSchemaTreeItem) |
| 513 | */ |
| 514 | typedef struct _xmlSchemaAttributeUse xmlSchemaAttributeUse; |
| 515 | typedef xmlSchemaAttributeUse *xmlSchemaAttributeUsePtr; |
| 516 | struct _xmlSchemaAttributeUse { |
| 517 | xmlSchemaTypeType type; |
| 518 | xmlSchemaAnnotPtr annot; |
| 519 | xmlSchemaAttributeUsePtr next; /* The next attr. use. */ |
| 520 | /* |
| 521 | * The attr. decl. OR a QName-ref. to an attr. decl. OR |
| 522 | * a QName-ref. to an attribute group definition. |
| 523 | */ |
| 524 | xmlSchemaAttributePtr attrDecl; |
| 525 | |
| 526 | int flags; |
| 527 | xmlNodePtr node; |
| 528 | int occurs; /* required, optional */ |
| 529 | const xmlChar * defValue; |
| 530 | xmlSchemaValPtr defVal; |
| 531 | }; |
| 532 | |
| 533 | /** |
| 534 | * xmlSchemaAttributeUseProhibPtr: |
| 535 | * |
| 536 | * A helper component to reflect attribute prohibitions. |
| 537 | * (Extends xmlSchemaBasicItem) |
| 538 | */ |
| 539 | typedef struct _xmlSchemaAttributeUseProhib xmlSchemaAttributeUseProhib; |
| 540 | typedef xmlSchemaAttributeUseProhib *xmlSchemaAttributeUseProhibPtr; |
| 541 | struct _xmlSchemaAttributeUseProhib { |
| 542 | xmlSchemaTypeType type; /* == XML_SCHEMA_EXTRA_ATTR_USE_PROHIB */ |
| 543 | xmlNodePtr node; |
| 544 | const xmlChar *name; |
| 545 | const xmlChar *targetNamespace; |
| 546 | int isRef; |
| 547 | }; |
| 548 | |
| 549 | /** |
| 550 | * xmlSchemaRedef: |
| 551 | */ |
| 552 | typedef struct _xmlSchemaRedef xmlSchemaRedef; |
| 553 | typedef xmlSchemaRedef *xmlSchemaRedefPtr; |
| 554 | struct _xmlSchemaRedef { |
| 555 | xmlSchemaRedefPtr next; |
| 556 | xmlSchemaBasicItemPtr item; /* The redefining component. */ |
| 557 | xmlSchemaBasicItemPtr reference; /* The referencing component. */ |
| 558 | xmlSchemaBasicItemPtr target; /* The to-be-redefined component. */ |
| 559 | const xmlChar *refName; /* The name of the to-be-redefined component. */ |
| 560 | const xmlChar *refTargetNs; /* The target namespace of the |
| 561 | to-be-redefined comp. */ |
| 562 | xmlSchemaBucketPtr targetBucket; /* The redefined schema. */ |
| 563 | }; |
| 564 | |
| 565 | /** |
| 566 | * xmlSchemaConstructionCtxt: |
| 567 | */ |
| 568 | typedef struct _xmlSchemaConstructionCtxt xmlSchemaConstructionCtxt; |
| 569 | typedef xmlSchemaConstructionCtxt *xmlSchemaConstructionCtxtPtr; |
| 570 | struct _xmlSchemaConstructionCtxt { |
| 571 | xmlSchemaPtr mainSchema; /* The main schema. */ |
| 572 | xmlSchemaBucketPtr mainBucket; /* The main schema bucket */ |
| 573 | xmlDictPtr dict; |
| 574 | xmlSchemaItemListPtr buckets; /* List of schema buckets. */ |
| 575 | /* xmlSchemaItemListPtr relations; */ /* List of schema relations. */ |
| 576 | xmlSchemaBucketPtr bucket; /* The current schema bucket */ |
| 577 | xmlSchemaItemListPtr pending; /* All Components of all schemas that |
| 578 | need to be fixed. */ |
| 579 | xmlHashTablePtr substGroups; |
| 580 | xmlSchemaRedefPtr redefs; |
| 581 | xmlSchemaRedefPtr lastRedef; |
| 582 | }; |
| 583 | |
| 584 | #define XML_SCHEMAS_PARSE_ERROR1 1 |
| 585 | #define SCHEMAS_PARSE_OPTIONSXML_PARSE_NOENT XML_PARSE_NOENT |
| 586 | |
| 587 | struct _xmlSchemaParserCtxt { |
| 588 | int type; |
| 589 | void *errCtxt; /* user specific error context */ |
| 590 | xmlSchemaValidityErrorFunc error; /* the callback in case of errors */ |
| 591 | xmlSchemaValidityWarningFunc warning; /* the callback in case of warning */ |
| 592 | int err; |
| 593 | int nberrors; |
| 594 | xmlStructuredErrorFunc serror; |
| 595 | |
| 596 | xmlSchemaConstructionCtxtPtr constructor; |
| 597 | int ownsConstructor; /* TODO: Move this to parser *flags*. */ |
| 598 | |
| 599 | /* xmlSchemaPtr topschema; */ |
| 600 | /* xmlHashTablePtr namespaces; */ |
| 601 | |
| 602 | xmlSchemaPtr schema; /* The main schema in use */ |
| 603 | int counter; |
| 604 | |
| 605 | const xmlChar *URL; |
| 606 | xmlDocPtr doc; |
| 607 | int preserve; /* Whether the doc should be freed */ |
| 608 | |
| 609 | const char *buffer; |
| 610 | int size; |
| 611 | |
| 612 | /* |
| 613 | * Used to build complex element content models |
| 614 | */ |
| 615 | xmlAutomataPtr am; |
| 616 | xmlAutomataStatePtr start; |
| 617 | xmlAutomataStatePtr end; |
| 618 | xmlAutomataStatePtr state; |
| 619 | |
| 620 | xmlDictPtr dict; /* dictionnary for interned string names */ |
| 621 | xmlSchemaTypePtr ctxtType; /* The current context simple/complex type */ |
| 622 | int options; |
| 623 | xmlSchemaValidCtxtPtr vctxt; |
| 624 | int isS4S; |
| 625 | int isRedefine; |
| 626 | int xsiAssemble; |
| 627 | int stop; /* If the parser should stop; i.e. a critical error. */ |
| 628 | const xmlChar *targetNamespace; |
| 629 | xmlSchemaBucketPtr redefined; /* The schema to be redefined. */ |
| 630 | |
| 631 | xmlSchemaRedefPtr redef; /* Used for redefinitions. */ |
| 632 | int redefCounter; /* Used for redefinitions. */ |
| 633 | xmlSchemaItemListPtr attrProhibs; |
| 634 | }; |
| 635 | |
| 636 | /** |
| 637 | * xmlSchemaQNameRef: |
| 638 | * |
| 639 | * A component reference item (not a schema component) |
| 640 | * (Extends xmlSchemaBasicItem) |
| 641 | */ |
| 642 | typedef struct _xmlSchemaQNameRef xmlSchemaQNameRef; |
| 643 | typedef xmlSchemaQNameRef *xmlSchemaQNameRefPtr; |
| 644 | struct _xmlSchemaQNameRef { |
| 645 | xmlSchemaTypeType type; |
| 646 | xmlSchemaBasicItemPtr item; /* The resolved referenced item. */ |
| 647 | xmlSchemaTypeType itemType; |
| 648 | const xmlChar *name; |
| 649 | const xmlChar *targetNamespace; |
| 650 | xmlNodePtr node; |
| 651 | }; |
| 652 | |
| 653 | /** |
| 654 | * xmlSchemaParticle: |
| 655 | * |
| 656 | * A particle component. |
| 657 | * (Extends xmlSchemaTreeItem) |
| 658 | */ |
| 659 | typedef struct _xmlSchemaParticle xmlSchemaParticle; |
| 660 | typedef xmlSchemaParticle *xmlSchemaParticlePtr; |
| 661 | struct _xmlSchemaParticle { |
| 662 | xmlSchemaTypeType type; |
| 663 | xmlSchemaAnnotPtr annot; |
| 664 | xmlSchemaTreeItemPtr next; /* next particle */ |
| 665 | xmlSchemaTreeItemPtr children; /* the "term" (e.g. a model group, |
| 666 | a group definition, a XML_SCHEMA_EXTRA_QNAMEREF (if a reference), |
| 667 | etc.) */ |
| 668 | int minOccurs; |
| 669 | int maxOccurs; |
| 670 | xmlNodePtr node; |
| 671 | }; |
| 672 | |
| 673 | /** |
| 674 | * xmlSchemaModelGroup: |
| 675 | * |
| 676 | * A model group component. |
| 677 | * (Extends xmlSchemaTreeItem) |
| 678 | */ |
| 679 | typedef struct _xmlSchemaModelGroup xmlSchemaModelGroup; |
| 680 | typedef xmlSchemaModelGroup *xmlSchemaModelGroupPtr; |
| 681 | struct _xmlSchemaModelGroup { |
| 682 | xmlSchemaTypeType type; /* XML_SCHEMA_TYPE_SEQUENCE, XML_SCHEMA_TYPE_CHOICE, XML_SCHEMA_TYPE_ALL */ |
| 683 | xmlSchemaAnnotPtr annot; |
| 684 | xmlSchemaTreeItemPtr next; /* not used */ |
| 685 | xmlSchemaTreeItemPtr children; /* first particle (OR "element decl" OR "wildcard") */ |
| 686 | xmlNodePtr node; |
| 687 | }; |
| 688 | |
| 689 | #define XML_SCHEMA_MODEL_GROUP_DEF_MARKED1<<0 1<<0 |
| 690 | #define XML_SCHEMA_MODEL_GROUP_DEF_REDEFINED1<<1 1<<1 |
| 691 | /** |
| 692 | * xmlSchemaModelGroupDef: |
| 693 | * |
| 694 | * A model group definition component. |
| 695 | * (Extends xmlSchemaTreeItem) |
| 696 | */ |
| 697 | typedef struct _xmlSchemaModelGroupDef xmlSchemaModelGroupDef; |
| 698 | typedef xmlSchemaModelGroupDef *xmlSchemaModelGroupDefPtr; |
| 699 | struct _xmlSchemaModelGroupDef { |
| 700 | xmlSchemaTypeType type; /* XML_SCHEMA_TYPE_GROUP */ |
| 701 | xmlSchemaAnnotPtr annot; |
| 702 | xmlSchemaTreeItemPtr next; /* not used */ |
| 703 | xmlSchemaTreeItemPtr children; /* the "model group" */ |
| 704 | const xmlChar *name; |
| 705 | const xmlChar *targetNamespace; |
| 706 | xmlNodePtr node; |
| 707 | int flags; |
| 708 | }; |
| 709 | |
| 710 | typedef struct _xmlSchemaIDC xmlSchemaIDC; |
| 711 | typedef xmlSchemaIDC *xmlSchemaIDCPtr; |
| 712 | |
| 713 | /** |
| 714 | * xmlSchemaIDCSelect: |
| 715 | * |
| 716 | * The identity-constraint "field" and "selector" item, holding the |
| 717 | * XPath expression. |
| 718 | */ |
| 719 | typedef struct _xmlSchemaIDCSelect xmlSchemaIDCSelect; |
| 720 | typedef xmlSchemaIDCSelect *xmlSchemaIDCSelectPtr; |
| 721 | struct _xmlSchemaIDCSelect { |
| 722 | xmlSchemaIDCSelectPtr next; |
| 723 | xmlSchemaIDCPtr idc; |
| 724 | int index; /* an index position if significant for IDC key-sequences */ |
| 725 | const xmlChar *xpath; /* the XPath expression */ |
| 726 | void *xpathComp; /* the compiled XPath expression */ |
| 727 | }; |
| 728 | |
| 729 | /** |
| 730 | * xmlSchemaIDC: |
| 731 | * |
| 732 | * The identity-constraint definition component. |
| 733 | * (Extends xmlSchemaAnnotItem) |
| 734 | */ |
| 735 | |
| 736 | struct _xmlSchemaIDC { |
| 737 | xmlSchemaTypeType type; |
| 738 | xmlSchemaAnnotPtr annot; |
| 739 | xmlSchemaIDCPtr next; |
| 740 | xmlNodePtr node; |
| 741 | const xmlChar *name; |
| 742 | const xmlChar *targetNamespace; |
| 743 | xmlSchemaIDCSelectPtr selector; |
| 744 | xmlSchemaIDCSelectPtr fields; |
| 745 | int nbFields; |
| 746 | xmlSchemaQNameRefPtr ref; |
| 747 | }; |
| 748 | |
| 749 | /** |
| 750 | * xmlSchemaIDCAug: |
| 751 | * |
| 752 | * The augmented IDC information used for validation. |
| 753 | */ |
| 754 | typedef struct _xmlSchemaIDCAug xmlSchemaIDCAug; |
| 755 | typedef xmlSchemaIDCAug *xmlSchemaIDCAugPtr; |
| 756 | struct _xmlSchemaIDCAug { |
| 757 | xmlSchemaIDCAugPtr next; /* next in a list */ |
| 758 | xmlSchemaIDCPtr def; /* the IDC definition */ |
| 759 | int keyrefDepth; /* the lowest tree level to which IDC |
| 760 | tables need to be bubbled upwards */ |
| 761 | }; |
| 762 | |
| 763 | /** |
| 764 | * xmlSchemaPSVIIDCKeySequence: |
| 765 | * |
| 766 | * The key sequence of a node table item. |
| 767 | */ |
| 768 | typedef struct _xmlSchemaPSVIIDCKey xmlSchemaPSVIIDCKey; |
| 769 | typedef xmlSchemaPSVIIDCKey *xmlSchemaPSVIIDCKeyPtr; |
| 770 | struct _xmlSchemaPSVIIDCKey { |
| 771 | xmlSchemaTypePtr type; |
| 772 | xmlSchemaValPtr val; |
| 773 | }; |
| 774 | |
| 775 | /** |
| 776 | * xmlSchemaPSVIIDCNode: |
| 777 | * |
| 778 | * The node table item of a node table. |
| 779 | */ |
| 780 | typedef struct _xmlSchemaPSVIIDCNode xmlSchemaPSVIIDCNode; |
| 781 | typedef xmlSchemaPSVIIDCNode *xmlSchemaPSVIIDCNodePtr; |
| 782 | struct _xmlSchemaPSVIIDCNode { |
| 783 | xmlNodePtr node; |
| 784 | xmlSchemaPSVIIDCKeyPtr *keys; |
| 785 | int nodeLine; |
| 786 | int nodeQNameID; |
| 787 | |
| 788 | }; |
| 789 | |
| 790 | /** |
| 791 | * xmlSchemaPSVIIDCBinding: |
| 792 | * |
| 793 | * The identity-constraint binding item of the [identity-constraint table]. |
| 794 | */ |
| 795 | typedef struct _xmlSchemaPSVIIDCBinding xmlSchemaPSVIIDCBinding; |
| 796 | typedef xmlSchemaPSVIIDCBinding *xmlSchemaPSVIIDCBindingPtr; |
| 797 | struct _xmlSchemaPSVIIDCBinding { |
| 798 | xmlSchemaPSVIIDCBindingPtr next; /* next binding of a specific node */ |
| 799 | xmlSchemaIDCPtr definition; /* the IDC definition */ |
| 800 | xmlSchemaPSVIIDCNodePtr *nodeTable; /* array of key-sequences */ |
| 801 | int nbNodes; /* number of entries in the node table */ |
| 802 | int sizeNodes; /* size of the node table */ |
| 803 | xmlSchemaItemListPtr dupls; |
| 804 | }; |
| 805 | |
| 806 | |
| 807 | #define XPATH_STATE_OBJ_TYPE_IDC_SELECTOR1 1 |
| 808 | #define XPATH_STATE_OBJ_TYPE_IDC_FIELD2 2 |
| 809 | |
| 810 | #define XPATH_STATE_OBJ_MATCHES-2 -2 |
| 811 | #define XPATH_STATE_OBJ_BLOCKED-3 -3 |
| 812 | |
| 813 | typedef struct _xmlSchemaIDCMatcher xmlSchemaIDCMatcher; |
| 814 | typedef xmlSchemaIDCMatcher *xmlSchemaIDCMatcherPtr; |
| 815 | |
| 816 | /** |
| 817 | * xmlSchemaIDCStateObj: |
| 818 | * |
| 819 | * The state object used to evaluate XPath expressions. |
| 820 | */ |
| 821 | typedef struct _xmlSchemaIDCStateObj xmlSchemaIDCStateObj; |
| 822 | typedef xmlSchemaIDCStateObj *xmlSchemaIDCStateObjPtr; |
| 823 | struct _xmlSchemaIDCStateObj { |
| 824 | int type; |
| 825 | xmlSchemaIDCStateObjPtr next; /* next if in a list */ |
| 826 | int depth; /* depth of creation */ |
| 827 | int *history; /* list of (depth, state-id) tuples */ |
| 828 | int nbHistory; |
| 829 | int sizeHistory; |
| 830 | xmlSchemaIDCMatcherPtr matcher; /* the correspondent field/selector |
| 831 | matcher */ |
| 832 | xmlSchemaIDCSelectPtr sel; |
| 833 | void *xpathCtxt; |
| 834 | }; |
| 835 | |
| 836 | #define IDC_MATCHER0 0 |
| 837 | |
| 838 | /** |
| 839 | * xmlSchemaIDCMatcher: |
| 840 | * |
| 841 | * Used to evaluate IDC selectors (and fields). |
| 842 | */ |
| 843 | struct _xmlSchemaIDCMatcher { |
| 844 | int type; |
| 845 | int depth; /* the tree depth at creation time */ |
| 846 | xmlSchemaIDCMatcherPtr next; /* next in the list */ |
| 847 | xmlSchemaIDCMatcherPtr nextCached; /* next in the cache list */ |
| 848 | xmlSchemaIDCAugPtr aidc; /* the augmented IDC item */ |
| 849 | int idcType; |
| 850 | xmlSchemaPSVIIDCKeyPtr **keySeqs; /* the key-sequences of the target |
| 851 | elements */ |
| 852 | int sizeKeySeqs; |
| 853 | xmlSchemaItemListPtr targets; /* list of target-node |
| 854 | (xmlSchemaPSVIIDCNodePtr) entries */ |
| 855 | }; |
| 856 | |
| 857 | /* |
| 858 | * Element info flags. |
| 859 | */ |
| 860 | #define XML_SCHEMA_NODE_INFO_FLAG_OWNED_NAMES1<<0 1<<0 |
| 861 | #define XML_SCHEMA_NODE_INFO_FLAG_OWNED_VALUES1<<1 1<<1 |
| 862 | #define XML_SCHEMA_ELEM_INFO_NILLED1<<2 1<<2 |
| 863 | #define XML_SCHEMA_ELEM_INFO_LOCAL_TYPE1<<3 1<<3 |
| 864 | |
| 865 | #define XML_SCHEMA_NODE_INFO_VALUE_NEEDED1<<4 1<<4 |
| 866 | #define XML_SCHEMA_ELEM_INFO_EMPTY1<<5 1<<5 |
| 867 | #define XML_SCHEMA_ELEM_INFO_HAS_CONTENT1<<6 1<<6 |
| 868 | |
| 869 | #define XML_SCHEMA_ELEM_INFO_HAS_ELEM_CONTENT1<<7 1<<7 |
| 870 | #define XML_SCHEMA_ELEM_INFO_ERR_BAD_CONTENT1<<8 1<<8 |
| 871 | #define XML_SCHEMA_NODE_INFO_ERR_NOT_EXPECTED1<<9 1<<9 |
| 872 | #define XML_SCHEMA_NODE_INFO_ERR_BAD_TYPE1<<10 1<<10 |
| 873 | |
| 874 | /** |
| 875 | * xmlSchemaNodeInfo: |
| 876 | * |
| 877 | * Holds information of an element node. |
| 878 | */ |
| 879 | struct _xmlSchemaNodeInfo { |
| 880 | int nodeType; |
| 881 | xmlNodePtr node; |
| 882 | int nodeLine; |
| 883 | const xmlChar *localName; |
| 884 | const xmlChar *nsName; |
| 885 | const xmlChar *value; |
| 886 | xmlSchemaValPtr val; /* the pre-computed value if any */ |
| 887 | xmlSchemaTypePtr typeDef; /* the complex/simple type definition if any */ |
| 888 | |
| 889 | int flags; /* combination of node info flags */ |
| 890 | |
| 891 | int valNeeded; |
| 892 | int normVal; |
| 893 | |
| 894 | xmlSchemaElementPtr decl; /* the element/attribute declaration */ |
| 895 | int depth; |
| 896 | xmlSchemaPSVIIDCBindingPtr idcTable; /* the table of PSVI IDC bindings |
| 897 | for the scope element*/ |
| 898 | xmlSchemaIDCMatcherPtr idcMatchers; /* the IDC matchers for the scope |
| 899 | element */ |
| 900 | xmlRegExecCtxtPtr regexCtxt; |
| 901 | |
| 902 | const xmlChar **nsBindings; /* Namespace bindings on this element */ |
| 903 | int nbNsBindings; |
| 904 | int sizeNsBindings; |
| 905 | |
| 906 | int hasKeyrefs; |
| 907 | int appliedXPath; /* Indicates that an XPath has been applied. */ |
| 908 | }; |
| 909 | |
| 910 | #define XML_SCHEMAS_ATTR_UNKNOWN1 1 |
| 911 | #define XML_SCHEMAS_ATTR_ASSESSED2 2 |
| 912 | #define XML_SCHEMAS_ATTR_PROHIBITED3 3 |
| 913 | #define XML_SCHEMAS_ATTR_ERR_MISSING4 4 |
| 914 | #define XML_SCHEMAS_ATTR_INVALID_VALUE5 5 |
| 915 | #define XML_SCHEMAS_ATTR_ERR_NO_TYPE6 6 |
| 916 | #define XML_SCHEMAS_ATTR_ERR_FIXED_VALUE7 7 |
| 917 | #define XML_SCHEMAS_ATTR_DEFAULT8 8 |
| 918 | #define XML_SCHEMAS_ATTR_VALIDATE_VALUE9 9 |
| 919 | #define XML_SCHEMAS_ATTR_ERR_WILD_STRICT_NO_DECL10 10 |
| 920 | #define XML_SCHEMAS_ATTR_HAS_ATTR_USE11 11 |
| 921 | #define XML_SCHEMAS_ATTR_HAS_ATTR_DECL12 12 |
| 922 | #define XML_SCHEMAS_ATTR_WILD_SKIP13 13 |
| 923 | #define XML_SCHEMAS_ATTR_WILD_LAX_NO_DECL14 14 |
| 924 | #define XML_SCHEMAS_ATTR_ERR_WILD_DUPLICATE_ID15 15 |
| 925 | #define XML_SCHEMAS_ATTR_ERR_WILD_AND_USE_ID16 16 |
| 926 | #define XML_SCHEMAS_ATTR_META17 17 |
| 927 | /* |
| 928 | * @metaType values of xmlSchemaAttrInfo. |
| 929 | */ |
| 930 | #define XML_SCHEMA_ATTR_INFO_META_XSI_TYPE1 1 |
| 931 | #define XML_SCHEMA_ATTR_INFO_META_XSI_NIL2 2 |
| 932 | #define XML_SCHEMA_ATTR_INFO_META_XSI_SCHEMA_LOC3 3 |
| 933 | #define XML_SCHEMA_ATTR_INFO_META_XSI_NO_NS_SCHEMA_LOC4 4 |
| 934 | #define XML_SCHEMA_ATTR_INFO_META_XMLNS5 5 |
| 935 | |
| 936 | typedef struct _xmlSchemaAttrInfo xmlSchemaAttrInfo; |
| 937 | typedef xmlSchemaAttrInfo *xmlSchemaAttrInfoPtr; |
| 938 | struct _xmlSchemaAttrInfo { |
| 939 | int nodeType; |
| 940 | xmlNodePtr node; |
| 941 | int nodeLine; |
| 942 | const xmlChar *localName; |
| 943 | const xmlChar *nsName; |
| 944 | const xmlChar *value; |
| 945 | xmlSchemaValPtr val; /* the pre-computed value if any */ |
| 946 | xmlSchemaTypePtr typeDef; /* the complex/simple type definition if any */ |
| 947 | int flags; /* combination of node info flags */ |
| 948 | |
| 949 | xmlSchemaAttributePtr decl; /* the attribute declaration */ |
| 950 | xmlSchemaAttributeUsePtr use; /* the attribute use */ |
| 951 | int state; |
| 952 | int metaType; |
| 953 | const xmlChar *vcValue; /* the value constraint value */ |
| 954 | xmlSchemaNodeInfoPtr parent; |
| 955 | }; |
| 956 | |
| 957 | |
| 958 | #define XML_SCHEMA_VALID_CTXT_FLAG_STREAM1 1 |
| 959 | /** |
| 960 | * xmlSchemaValidCtxt: |
| 961 | * |
| 962 | * A Schemas validation context |
| 963 | */ |
| 964 | struct _xmlSchemaValidCtxt { |
| 965 | int type; |
| 966 | void *errCtxt; /* user specific data block */ |
| 967 | xmlSchemaValidityErrorFunc error; /* the callback in case of errors */ |
| 968 | xmlSchemaValidityWarningFunc warning; /* the callback in case of warning */ |
| 969 | xmlStructuredErrorFunc serror; |
| 970 | |
| 971 | xmlSchemaPtr schema; /* The schema in use */ |
| 972 | xmlDocPtr doc; |
| 973 | xmlParserInputBufferPtr input; |
| 974 | xmlCharEncoding enc; |
| 975 | xmlSAXHandlerPtr sax; |
| 976 | xmlParserCtxtPtr parserCtxt; |
| 977 | void *user_data; /* TODO: What is this for? */ |
| 978 | |
| 979 | int err; |
| 980 | int nberrors; |
| 981 | |
| 982 | xmlNodePtr node; |
| 983 | xmlNodePtr cur; |
| 984 | /* xmlSchemaTypePtr type; */ |
| 985 | |
| 986 | xmlRegExecCtxtPtr regexp; |
| 987 | xmlSchemaValPtr value; |
| 988 | |
| 989 | int valueWS; |
| 990 | int options; |
| 991 | xmlNodePtr validationRoot; |
| 992 | xmlSchemaParserCtxtPtr pctxt; |
| 993 | int xsiAssemble; |
| 994 | |
| 995 | int depth; |
| 996 | xmlSchemaNodeInfoPtr *elemInfos; /* array of element informations */ |
| 997 | int sizeElemInfos; |
| 998 | xmlSchemaNodeInfoPtr inode; /* the current element information */ |
| 999 | |
| 1000 | xmlSchemaIDCAugPtr aidcs; /* a list of augmented IDC informations */ |
| 1001 | |
| 1002 | xmlSchemaIDCStateObjPtr xpathStates; /* first active state object. */ |
| 1003 | xmlSchemaIDCStateObjPtr xpathStatePool; /* first stored state object. */ |
| 1004 | xmlSchemaIDCMatcherPtr idcMatcherCache; /* Cache for IDC matcher objects. */ |
| 1005 | |
| 1006 | xmlSchemaPSVIIDCNodePtr *idcNodes; /* list of all IDC node-table entries*/ |
| 1007 | int nbIdcNodes; |
| 1008 | int sizeIdcNodes; |
| 1009 | |
| 1010 | xmlSchemaPSVIIDCKeyPtr *idcKeys; /* list of all IDC node-table entries */ |
| 1011 | int nbIdcKeys; |
| 1012 | int sizeIdcKeys; |
| 1013 | |
| 1014 | int flags; |
| 1015 | |
| 1016 | xmlDictPtr dict; |
| 1017 | |
| 1018 | #ifdef LIBXML_READER_ENABLED |
| 1019 | xmlTextReaderPtr reader; |
| 1020 | #endif |
| 1021 | |
| 1022 | xmlSchemaAttrInfoPtr *attrInfos; |
| 1023 | int nbAttrInfos; |
| 1024 | int sizeAttrInfos; |
| 1025 | |
| 1026 | int skipDepth; |
| 1027 | xmlSchemaItemListPtr nodeQNames; |
| 1028 | int hasKeyrefs; |
| 1029 | int createIDCNodeTables; |
| 1030 | int psviExposeIDCNodeTables; |
| 1031 | }; |
| 1032 | |
| 1033 | /** |
| 1034 | * xmlSchemaSubstGroup: |
| 1035 | * |
| 1036 | * |
| 1037 | */ |
| 1038 | typedef struct _xmlSchemaSubstGroup xmlSchemaSubstGroup; |
| 1039 | typedef xmlSchemaSubstGroup *xmlSchemaSubstGroupPtr; |
| 1040 | struct _xmlSchemaSubstGroup { |
| 1041 | xmlSchemaElementPtr head; |
| 1042 | xmlSchemaItemListPtr members; |
| 1043 | }; |
| 1044 | |
| 1045 | /************************************************************************ |
| 1046 | * * |
| 1047 | * Some predeclarations * |
| 1048 | * * |
| 1049 | ************************************************************************/ |
| 1050 | |
| 1051 | static int xmlSchemaParseInclude(xmlSchemaParserCtxtPtr ctxt, |
| 1052 | xmlSchemaPtr schema, |
| 1053 | xmlNodePtr node); |
| 1054 | static int xmlSchemaParseRedefine(xmlSchemaParserCtxtPtr ctxt, |
| 1055 | xmlSchemaPtr schema, |
| 1056 | xmlNodePtr node); |
| 1057 | static int |
| 1058 | xmlSchemaTypeFixup(xmlSchemaTypePtr type, |
| 1059 | xmlSchemaAbstractCtxtPtr ctxt); |
| 1060 | static const xmlChar * |
| 1061 | xmlSchemaFacetTypeToString(xmlSchemaTypeType type); |
| 1062 | static int |
| 1063 | xmlSchemaParseImport(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema, |
| 1064 | xmlNodePtr node); |
| 1065 | static int |
| 1066 | xmlSchemaCheckFacetValues(xmlSchemaTypePtr typeDecl, |
| 1067 | xmlSchemaParserCtxtPtr ctxt); |
| 1068 | static void |
| 1069 | xmlSchemaClearValidCtxt(xmlSchemaValidCtxtPtr vctxt); |
| 1070 | static xmlSchemaWhitespaceValueType |
| 1071 | xmlSchemaGetWhiteSpaceFacetValue(xmlSchemaTypePtr type); |
| 1072 | static xmlSchemaTreeItemPtr |
| 1073 | xmlSchemaParseModelGroup(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema, |
| 1074 | xmlNodePtr node, xmlSchemaTypeType type, |
| 1075 | int withParticle); |
| 1076 | static const xmlChar * |
| 1077 | xmlSchemaGetComponentTypeStr(xmlSchemaBasicItemPtr item); |
| 1078 | static xmlSchemaTypeLinkPtr |
| 1079 | xmlSchemaGetUnionSimpleTypeMemberTypes(xmlSchemaTypePtr type); |
| 1080 | static void |
| 1081 | xmlSchemaInternalErr(xmlSchemaAbstractCtxtPtr actxt, |
| 1082 | const char *funcName, |
| 1083 | const char *message); |
| 1084 | static int |
| 1085 | xmlSchemaCheckCOSSTDerivedOK(xmlSchemaAbstractCtxtPtr ctxt, |
| 1086 | xmlSchemaTypePtr type, |
| 1087 | xmlSchemaTypePtr baseType, |
| 1088 | int subset); |
| 1089 | static void |
| 1090 | xmlSchemaCheckElementDeclComponent(xmlSchemaElementPtr elemDecl, |
| 1091 | xmlSchemaParserCtxtPtr ctxt); |
| 1092 | static void |
| 1093 | xmlSchemaComponentListFree(xmlSchemaItemListPtr list); |
| 1094 | static xmlSchemaQNameRefPtr |
| 1095 | xmlSchemaParseAttributeGroupRef(xmlSchemaParserCtxtPtr pctxt, |
| 1096 | xmlSchemaPtr schema, |
| 1097 | xmlNodePtr node); |
| 1098 | |
| 1099 | /************************************************************************ |
| 1100 | * * |
| 1101 | * Helper functions * |
| 1102 | * * |
| 1103 | ************************************************************************/ |
| 1104 | |
| 1105 | /** |
| 1106 | * xmlSchemaItemTypeToStr: |
| 1107 | * @type: the type of the schema item |
| 1108 | * |
| 1109 | * Returns the component name of a schema item. |
| 1110 | */ |
| 1111 | static const xmlChar * |
| 1112 | xmlSchemaItemTypeToStr(xmlSchemaTypeType type) |
| 1113 | { |
| 1114 | switch (type) { |
| 1115 | case XML_SCHEMA_TYPE_BASIC: |
| 1116 | return(BAD_CAST(xmlChar *) "simple type definition"); |
| 1117 | case XML_SCHEMA_TYPE_SIMPLE: |
| 1118 | return(BAD_CAST(xmlChar *) "simple type definition"); |
| 1119 | case XML_SCHEMA_TYPE_COMPLEX: |
| 1120 | return(BAD_CAST(xmlChar *) "complex type definition"); |
| 1121 | case XML_SCHEMA_TYPE_ELEMENT: |
| 1122 | return(BAD_CAST(xmlChar *) "element declaration"); |
| 1123 | case XML_SCHEMA_TYPE_ATTRIBUTE_USE: |
| 1124 | return(BAD_CAST(xmlChar *) "attribute use"); |
| 1125 | case XML_SCHEMA_TYPE_ATTRIBUTE: |
| 1126 | return(BAD_CAST(xmlChar *) "attribute declaration"); |
| 1127 | case XML_SCHEMA_TYPE_GROUP: |
| 1128 | return(BAD_CAST(xmlChar *) "model group definition"); |
| 1129 | case XML_SCHEMA_TYPE_ATTRIBUTEGROUP: |
| 1130 | return(BAD_CAST(xmlChar *) "attribute group definition"); |
| 1131 | case XML_SCHEMA_TYPE_NOTATION: |
| 1132 | return(BAD_CAST(xmlChar *) "notation declaration"); |
| 1133 | case XML_SCHEMA_TYPE_SEQUENCE: |
| 1134 | return(BAD_CAST(xmlChar *) "model group (sequence)"); |
| 1135 | case XML_SCHEMA_TYPE_CHOICE: |
| 1136 | return(BAD_CAST(xmlChar *) "model group (choice)"); |
| 1137 | case XML_SCHEMA_TYPE_ALL: |
| 1138 | return(BAD_CAST(xmlChar *) "model group (all)"); |
| 1139 | case XML_SCHEMA_TYPE_PARTICLE: |
| 1140 | return(BAD_CAST(xmlChar *) "particle"); |
| 1141 | case XML_SCHEMA_TYPE_IDC_UNIQUE: |
| 1142 | return(BAD_CAST(xmlChar *) "unique identity-constraint"); |
| 1143 | /* return(BAD_CAST "IDC (unique)"); */ |
| 1144 | case XML_SCHEMA_TYPE_IDC_KEY: |
| 1145 | return(BAD_CAST(xmlChar *) "key identity-constraint"); |
| 1146 | /* return(BAD_CAST "IDC (key)"); */ |
| 1147 | case XML_SCHEMA_TYPE_IDC_KEYREF: |
| 1148 | return(BAD_CAST(xmlChar *) "keyref identity-constraint"); |
| 1149 | /* return(BAD_CAST "IDC (keyref)"); */ |
| 1150 | case XML_SCHEMA_TYPE_ANY: |
| 1151 | return(BAD_CAST(xmlChar *) "wildcard (any)"); |
| 1152 | case XML_SCHEMA_EXTRA_QNAMEREF: |
| 1153 | return(BAD_CAST(xmlChar *) "[helper component] QName reference"); |
| 1154 | case XML_SCHEMA_EXTRA_ATTR_USE_PROHIB: |
| 1155 | return(BAD_CAST(xmlChar *) "[helper component] attribute use prohibition"); |
| 1156 | default: |
| 1157 | return(BAD_CAST(xmlChar *) "Not a schema component"); |
| 1158 | } |
| 1159 | } |
| 1160 | |
| 1161 | /** |
| 1162 | * xmlSchemaGetComponentTypeStr: |
| 1163 | * @type: the type of the schema item |
| 1164 | * |
| 1165 | * Returns the component name of a schema item. |
| 1166 | */ |
| 1167 | static const xmlChar * |
| 1168 | xmlSchemaGetComponentTypeStr(xmlSchemaBasicItemPtr item) |
| 1169 | { |
| 1170 | switch (item->type) { |
| 1171 | case XML_SCHEMA_TYPE_BASIC: |
| 1172 | if (WXS_IS_COMPLEX(WXS_TYPE_CAST item)((((xmlSchemaTypePtr) item)->type == XML_SCHEMA_TYPE_COMPLEX ) || (((xmlSchemaTypePtr) item)->builtInType == XML_SCHEMAS_ANYTYPE ))) |
| 1173 | return(BAD_CAST(xmlChar *) "complex type definition"); |
| 1174 | else |
| 1175 | return(BAD_CAST(xmlChar *) "simple type definition"); |
| 1176 | default: |
| 1177 | return(xmlSchemaItemTypeToStr(item->type)); |
| 1178 | } |
| 1179 | } |
| 1180 | |
| 1181 | /** |
| 1182 | * xmlSchemaGetComponentNode: |
| 1183 | * @item: a schema component |
| 1184 | * |
| 1185 | * Returns node associated with the schema component. |
| 1186 | * NOTE that such a node need not be available; plus, a component's |
| 1187 | * node need not to reflect the component directly, since there is no |
| 1188 | * one-to-one relationship between the XML Schema representation and |
| 1189 | * the component representation. |
| 1190 | */ |
| 1191 | static xmlNodePtr |
| 1192 | xmlSchemaGetComponentNode(xmlSchemaBasicItemPtr item) |
| 1193 | { |
| 1194 | switch (item->type) { |
| 1195 | case XML_SCHEMA_TYPE_ELEMENT: |
| 1196 | return (((xmlSchemaElementPtr) item)->node); |
| 1197 | case XML_SCHEMA_TYPE_ATTRIBUTE: |
| 1198 | return (((xmlSchemaAttributePtr) item)->node); |
| 1199 | case XML_SCHEMA_TYPE_COMPLEX: |
| 1200 | case XML_SCHEMA_TYPE_SIMPLE: |
| 1201 | return (((xmlSchemaTypePtr) item)->node); |
| 1202 | case XML_SCHEMA_TYPE_ANY: |
| 1203 | case XML_SCHEMA_TYPE_ANY_ATTRIBUTE: |
| 1204 | return (((xmlSchemaWildcardPtr) item)->node); |
| 1205 | case XML_SCHEMA_TYPE_PARTICLE: |
| 1206 | return (((xmlSchemaParticlePtr) item)->node); |
| 1207 | case XML_SCHEMA_TYPE_SEQUENCE: |
| 1208 | case XML_SCHEMA_TYPE_CHOICE: |
| 1209 | case XML_SCHEMA_TYPE_ALL: |
| 1210 | return (((xmlSchemaModelGroupPtr) item)->node); |
| 1211 | case XML_SCHEMA_TYPE_GROUP: |
| 1212 | return (((xmlSchemaModelGroupDefPtr) item)->node); |
| 1213 | case XML_SCHEMA_TYPE_ATTRIBUTEGROUP: |
| 1214 | return (((xmlSchemaAttributeGroupPtr) item)->node); |
| 1215 | case XML_SCHEMA_TYPE_IDC_UNIQUE: |
| 1216 | case XML_SCHEMA_TYPE_IDC_KEY: |
| 1217 | case XML_SCHEMA_TYPE_IDC_KEYREF: |
| 1218 | return (((xmlSchemaIDCPtr) item)->node); |
| 1219 | case XML_SCHEMA_EXTRA_QNAMEREF: |
| 1220 | return(((xmlSchemaQNameRefPtr) item)->node); |
| 1221 | /* TODO: What to do with NOTATIONs? |
| 1222 | case XML_SCHEMA_TYPE_NOTATION: |
| 1223 | return (((xmlSchemaNotationPtr) item)->node); |
| 1224 | */ |
| 1225 | case XML_SCHEMA_TYPE_ATTRIBUTE_USE: |
| 1226 | return (((xmlSchemaAttributeUsePtr) item)->node); |
| 1227 | default: |
| 1228 | return (NULL((void*)0)); |
| 1229 | } |
| 1230 | } |
| 1231 | |
| 1232 | #if 0 |
| 1233 | /** |
| 1234 | * xmlSchemaGetNextComponent: |
| 1235 | * @item: a schema component |
| 1236 | * |
| 1237 | * Returns the next sibling of the schema component. |
| 1238 | */ |
| 1239 | static xmlSchemaBasicItemPtr |
| 1240 | xmlSchemaGetNextComponent(xmlSchemaBasicItemPtr item) |
| 1241 | { |
| 1242 | switch (item->type) { |
| 1243 | case XML_SCHEMA_TYPE_ELEMENT: |
| 1244 | return ((xmlSchemaBasicItemPtr) ((xmlSchemaElementPtr) item)->next); |
| 1245 | case XML_SCHEMA_TYPE_ATTRIBUTE: |
| 1246 | return ((xmlSchemaBasicItemPtr) ((xmlSchemaAttributePtr) item)->next); |
| 1247 | case XML_SCHEMA_TYPE_COMPLEX: |
| 1248 | case XML_SCHEMA_TYPE_SIMPLE: |
| 1249 | return ((xmlSchemaBasicItemPtr) ((xmlSchemaTypePtr) item)->next); |
| 1250 | case XML_SCHEMA_TYPE_ANY: |
| 1251 | case XML_SCHEMA_TYPE_ANY_ATTRIBUTE: |
| 1252 | return (NULL((void*)0)); |
| 1253 | case XML_SCHEMA_TYPE_PARTICLE: |
| 1254 | return ((xmlSchemaBasicItemPtr) ((xmlSchemaParticlePtr) item)->next); |
| 1255 | case XML_SCHEMA_TYPE_SEQUENCE: |
| 1256 | case XML_SCHEMA_TYPE_CHOICE: |
| 1257 | case XML_SCHEMA_TYPE_ALL: |
| 1258 | return (NULL((void*)0)); |
| 1259 | case XML_SCHEMA_TYPE_GROUP: |
| 1260 | return (NULL((void*)0)); |
| 1261 | case XML_SCHEMA_TYPE_ATTRIBUTEGROUP: |
| 1262 | return ((xmlSchemaBasicItemPtr) ((xmlSchemaAttributeGroupPtr) item)->next); |
| 1263 | case XML_SCHEMA_TYPE_IDC_UNIQUE: |
| 1264 | case XML_SCHEMA_TYPE_IDC_KEY: |
| 1265 | case XML_SCHEMA_TYPE_IDC_KEYREF: |
| 1266 | return ((xmlSchemaBasicItemPtr) ((xmlSchemaIDCPtr) item)->next); |
| 1267 | default: |
| 1268 | return (NULL((void*)0)); |
| 1269 | } |
| 1270 | } |
| 1271 | #endif |
| 1272 | |
| 1273 | |
| 1274 | /** |
| 1275 | * xmlSchemaFormatQName: |
| 1276 | * @buf: the string buffer |
| 1277 | * @namespaceName: the namespace name |
| 1278 | * @localName: the local name |
| 1279 | * |
| 1280 | * Returns the given QName in the format "{namespaceName}localName" or |
| 1281 | * just "localName" if @namespaceName is NULL. |
| 1282 | * |
| 1283 | * Returns the localName if @namespaceName is NULL, a formatted |
| 1284 | * string otherwise. |
| 1285 | */ |
| 1286 | static const xmlChar* |
| 1287 | xmlSchemaFormatQName(xmlChar **buf, |
| 1288 | const xmlChar *namespaceName, |
| 1289 | const xmlChar *localName) |
| 1290 | { |
| 1291 | FREE_AND_NULL(*buf)if ((*buf) != ((void*)0)) { xmlFree((xmlChar *) (*buf)); *buf = ((void*)0); } |
| 1292 | if (namespaceName != NULL((void*)0)) { |
| 1293 | *buf = xmlStrdup(BAD_CAST(xmlChar *) "{"); |
| 1294 | *buf = xmlStrcat(*buf, namespaceName); |
| 1295 | *buf = xmlStrcat(*buf, BAD_CAST(xmlChar *) "}"); |
| 1296 | } |
| 1297 | if (localName != NULL((void*)0)) { |
| 1298 | if (namespaceName == NULL((void*)0)) |
| 1299 | return(localName); |
| 1300 | *buf = xmlStrcat(*buf, localName); |
| 1301 | } else { |
| 1302 | *buf = xmlStrcat(*buf, BAD_CAST(xmlChar *) "(NULL)"); |
| 1303 | } |
| 1304 | return ((const xmlChar *) *buf); |
| 1305 | } |
| 1306 | |
| 1307 | static const xmlChar* |
| 1308 | xmlSchemaFormatQNameNs(xmlChar **buf, xmlNsPtr ns, const xmlChar *localName) |
| 1309 | { |
| 1310 | if (ns != NULL((void*)0)) |
| 1311 | return (xmlSchemaFormatQName(buf, ns->href, localName)); |
| 1312 | else |
| 1313 | return (xmlSchemaFormatQName(buf, NULL((void*)0), localName)); |
| 1314 | } |
| 1315 | |
| 1316 | static const xmlChar * |
| 1317 | xmlSchemaGetComponentName(xmlSchemaBasicItemPtr item) |
| 1318 | { |
| 1319 | switch (item->type) { |
| 1320 | case XML_SCHEMA_TYPE_ELEMENT: |
| 1321 | return (((xmlSchemaElementPtr) item)->name); |
| 1322 | case XML_SCHEMA_TYPE_ATTRIBUTE: |
| 1323 | return (((xmlSchemaAttributePtr) item)->name); |
| 1324 | case XML_SCHEMA_TYPE_ATTRIBUTEGROUP: |
| 1325 | return (((xmlSchemaAttributeGroupPtr) item)->name); |
| 1326 | case XML_SCHEMA_TYPE_BASIC: |
| 1327 | case XML_SCHEMA_TYPE_SIMPLE: |
| 1328 | case XML_SCHEMA_TYPE_COMPLEX: |
| 1329 | return (((xmlSchemaTypePtr) item)->name); |
| 1330 | case XML_SCHEMA_TYPE_GROUP: |
| 1331 | return (((xmlSchemaModelGroupDefPtr) item)->name); |
| 1332 | case XML_SCHEMA_TYPE_IDC_KEY: |
| 1333 | case XML_SCHEMA_TYPE_IDC_UNIQUE: |
| 1334 | case XML_SCHEMA_TYPE_IDC_KEYREF: |
| 1335 | return (((xmlSchemaIDCPtr) item)->name); |
| 1336 | case XML_SCHEMA_TYPE_ATTRIBUTE_USE: |
| 1337 | if (WXS_ATTRUSE_DECL(item)(xmlSchemaAttributePtr) ((xmlSchemaAttributeUsePtr) (item))-> attrDecl != NULL((void*)0)) { |
| 1338 | return(xmlSchemaGetComponentName( |
| 1339 | WXS_BASIC_CAST(xmlSchemaBasicItemPtr) WXS_ATTRUSE_DECL(item)(xmlSchemaAttributePtr) ((xmlSchemaAttributeUsePtr) (item))-> attrDecl)); |
| 1340 | } else |
| 1341 | return(NULL((void*)0)); |
| 1342 | case XML_SCHEMA_EXTRA_QNAMEREF: |
| 1343 | return (((xmlSchemaQNameRefPtr) item)->name); |
| 1344 | case XML_SCHEMA_TYPE_NOTATION: |
| 1345 | return (((xmlSchemaNotationPtr) item)->name); |
| 1346 | default: |
| 1347 | /* |
| 1348 | * Other components cannot have names. |
| 1349 | */ |
| 1350 | break; |
| 1351 | } |
| 1352 | return (NULL((void*)0)); |
| 1353 | } |
| 1354 | |
| 1355 | #define xmlSchemaGetQNameRefName(r)((xmlSchemaQNameRefPtr) (r))->name (WXS_QNAME_CAST(xmlSchemaQNameRefPtr) (r))->name |
| 1356 | #define xmlSchemaGetQNameRefTargetNs(r)((xmlSchemaQNameRefPtr) (r))->targetNamespace (WXS_QNAME_CAST(xmlSchemaQNameRefPtr) (r))->targetNamespace |
| 1357 | /* |
| 1358 | static const xmlChar * |
| 1359 | xmlSchemaGetQNameRefName(void *ref) |
| 1360 | { |
| 1361 | return(((xmlSchemaQNameRefPtr) ref)->name); |
| 1362 | } |
| 1363 | |
| 1364 | static const xmlChar * |
| 1365 | xmlSchemaGetQNameRefTargetNs(void *ref) |
| 1366 | { |
| 1367 | return(((xmlSchemaQNameRefPtr) ref)->targetNamespace); |
| 1368 | } |
| 1369 | */ |
| 1370 | |
| 1371 | static const xmlChar * |
| 1372 | xmlSchemaGetComponentTargetNs(xmlSchemaBasicItemPtr item) |
| 1373 | { |
| 1374 | switch (item->type) { |
| 1375 | case XML_SCHEMA_TYPE_ELEMENT: |
| 1376 | return (((xmlSchemaElementPtr) item)->targetNamespace); |
| 1377 | case XML_SCHEMA_TYPE_ATTRIBUTE: |
| 1378 | return (((xmlSchemaAttributePtr) item)->targetNamespace); |
| 1379 | case XML_SCHEMA_TYPE_ATTRIBUTEGROUP: |
| 1380 | return (((xmlSchemaAttributeGroupPtr) item)->targetNamespace); |
| 1381 | case XML_SCHEMA_TYPE_BASIC: |
| 1382 | return (BAD_CAST(xmlChar *) "http://www.w3.org/2001/XMLSchema"); |
| 1383 | case XML_SCHEMA_TYPE_SIMPLE: |
| 1384 | case XML_SCHEMA_TYPE_COMPLEX: |
| 1385 | return (((xmlSchemaTypePtr) item)->targetNamespace); |
| 1386 | case XML_SCHEMA_TYPE_GROUP: |
| 1387 | return (((xmlSchemaModelGroupDefPtr) item)->targetNamespace); |
| 1388 | case XML_SCHEMA_TYPE_IDC_KEY: |
| 1389 | case XML_SCHEMA_TYPE_IDC_UNIQUE: |
| 1390 | case XML_SCHEMA_TYPE_IDC_KEYREF: |
| 1391 | return (((xmlSchemaIDCPtr) item)->targetNamespace); |
| 1392 | case XML_SCHEMA_TYPE_ATTRIBUTE_USE: |
| 1393 | if (WXS_ATTRUSE_DECL(item)(xmlSchemaAttributePtr) ((xmlSchemaAttributeUsePtr) (item))-> attrDecl != NULL((void*)0)) { |
| 1394 | return(xmlSchemaGetComponentTargetNs( |
| 1395 | WXS_BASIC_CAST(xmlSchemaBasicItemPtr) WXS_ATTRUSE_DECL(item)(xmlSchemaAttributePtr) ((xmlSchemaAttributeUsePtr) (item))-> attrDecl)); |
| 1396 | } |
| 1397 | /* TODO: Will returning NULL break something? */ |
| 1398 | break; |
| 1399 | case XML_SCHEMA_EXTRA_QNAMEREF: |
| 1400 | return (((xmlSchemaQNameRefPtr) item)->targetNamespace); |
| 1401 | case XML_SCHEMA_TYPE_NOTATION: |
| 1402 | return (((xmlSchemaNotationPtr) item)->targetNamespace); |
| 1403 | default: |
| 1404 | /* |
| 1405 | * Other components cannot have names. |
| 1406 | */ |
| 1407 | break; |
| 1408 | } |
| 1409 | return (NULL((void*)0)); |
| 1410 | } |
| 1411 | |
| 1412 | static const xmlChar* |
| 1413 | xmlSchemaGetComponentQName(xmlChar **buf, |
| 1414 | void *item) |
| 1415 | { |
| 1416 | return (xmlSchemaFormatQName(buf, |
| 1417 | xmlSchemaGetComponentTargetNs((xmlSchemaBasicItemPtr) item), |
| 1418 | xmlSchemaGetComponentName((xmlSchemaBasicItemPtr) item))); |
| 1419 | } |
| 1420 | |
| 1421 | static const xmlChar* |
| 1422 | xmlSchemaGetComponentDesignation(xmlChar **buf, void *item) |
| 1423 | { |
| 1424 | xmlChar *str = NULL((void*)0); |
| 1425 | |
| 1426 | *buf = xmlStrcat(*buf, WXS_ITEM_TYPE_NAME(item)xmlSchemaGetComponentTypeStr((xmlSchemaBasicItemPtr) (item))); |
| 1427 | *buf = xmlStrcat(*buf, BAD_CAST(xmlChar *) " '"); |
| 1428 | *buf = xmlStrcat(*buf, xmlSchemaGetComponentQName(&str, |
| 1429 | (xmlSchemaBasicItemPtr) item)); |
| 1430 | *buf = xmlStrcat(*buf, BAD_CAST(xmlChar *) "'"); |
| 1431 | FREE_AND_NULL(str)if ((str) != ((void*)0)) { xmlFree((xmlChar *) (str)); str = ( (void*)0); }; |
| 1432 | return(*buf); |
| 1433 | } |
| 1434 | |
| 1435 | static const xmlChar* |
| 1436 | xmlSchemaGetIDCDesignation(xmlChar **buf, xmlSchemaIDCPtr idc) |
| 1437 | { |
| 1438 | return(xmlSchemaGetComponentDesignation(buf, idc)); |
| 1439 | } |
| 1440 | |
| 1441 | /** |
| 1442 | * xmlSchemaWildcardPCToString: |
| 1443 | * @pc: the type of processContents |
| 1444 | * |
| 1445 | * Returns a string representation of the type of |
| 1446 | * processContents. |
| 1447 | */ |
| 1448 | static const xmlChar * |
| 1449 | xmlSchemaWildcardPCToString(int pc) |
| 1450 | { |
| 1451 | switch (pc) { |
| 1452 | case XML_SCHEMAS_ANY_SKIP1: |
| 1453 | return (BAD_CAST(xmlChar *) "skip"); |
| 1454 | case XML_SCHEMAS_ANY_LAX2: |
| 1455 | return (BAD_CAST(xmlChar *) "lax"); |
| 1456 | case XML_SCHEMAS_ANY_STRICT3: |
| 1457 | return (BAD_CAST(xmlChar *) "strict"); |
| 1458 | default: |
| 1459 | return (BAD_CAST(xmlChar *) "invalid process contents"); |
| 1460 | } |
| 1461 | } |
| 1462 | |
| 1463 | /** |
| 1464 | * xmlSchemaGetCanonValueWhtspExt: |
| 1465 | * @val: the precomputed value |
| 1466 | * @retValue: the returned value |
| 1467 | * @ws: the whitespace type of the value |
| 1468 | * |
| 1469 | * Get a the cononical representation of the value. |
| 1470 | * The caller has to free the returned retValue. |
| 1471 | * |
| 1472 | * Returns 0 if the value could be built and -1 in case of |
| 1473 | * API errors or if the value type is not supported yet. |
| 1474 | */ |
| 1475 | static int |
| 1476 | xmlSchemaGetCanonValueWhtspExt(xmlSchemaValPtr val, |
| 1477 | xmlSchemaWhitespaceValueType ws, |
| 1478 | xmlChar **retValue) |
| 1479 | { |
| 1480 | int list; |
| 1481 | xmlSchemaValType valType; |
| 1482 | const xmlChar *value, *value2 = NULL((void*)0); |
| 1483 | |
| 1484 | |
| 1485 | if ((retValue == NULL((void*)0)) || (val == NULL((void*)0))) |
| 1486 | return (-1); |
| 1487 | list = xmlSchemaValueGetNext(val) ? 1 : 0; |
| 1488 | *retValue = NULL((void*)0); |
| 1489 | do { |
| 1490 | value = NULL((void*)0); |
| 1491 | valType = xmlSchemaGetValType(val); |
| 1492 | switch (valType) { |
| 1493 | case XML_SCHEMAS_STRING: |
| 1494 | case XML_SCHEMAS_NORMSTRING: |
| 1495 | case XML_SCHEMAS_ANYSIMPLETYPE: |
| 1496 | value = xmlSchemaValueGetAsString(val); |
| 1497 | if (value != NULL((void*)0)) { |
| 1498 | if (ws == XML_SCHEMA_WHITESPACE_COLLAPSE) |
| 1499 | value2 = xmlSchemaCollapseString(value); |
| 1500 | else if (ws == XML_SCHEMA_WHITESPACE_REPLACE) |
| 1501 | value2 = xmlSchemaWhiteSpaceReplace(value); |
| 1502 | if (value2 != NULL((void*)0)) |
| 1503 | value = value2; |
| 1504 | } |
| 1505 | break; |
| 1506 | default: |
| 1507 | if (xmlSchemaGetCanonValue(val, &value2) == -1) { |
| 1508 | if (value2 != NULL((void*)0)) |
| 1509 | xmlFree((xmlChar *) value2); |
| 1510 | goto internal_error; |
| 1511 | } |
| 1512 | value = value2; |
| 1513 | } |
| 1514 | if (*retValue == NULL((void*)0)) |
| 1515 | if (value == NULL((void*)0)) { |
| 1516 | if (! list) |
| 1517 | *retValue = xmlStrdup(BAD_CAST(xmlChar *) ""); |
| 1518 | } else |
| 1519 | *retValue = xmlStrdup(value); |
| 1520 | else if (value != NULL((void*)0)) { |
| 1521 | /* List. */ |
| 1522 | *retValue = xmlStrcat((xmlChar *) *retValue, BAD_CAST(xmlChar *) " "); |
| 1523 | *retValue = xmlStrcat((xmlChar *) *retValue, value); |
| 1524 | } |
| 1525 | FREE_AND_NULL(value2)if ((value2) != ((void*)0)) { xmlFree((xmlChar *) (value2)); value2 = ((void*)0); } |
| 1526 | val = xmlSchemaValueGetNext(val); |
| 1527 | } while (val != NULL((void*)0)); |
| 1528 | |
| 1529 | return (0); |
| 1530 | internal_error: |
| 1531 | if (*retValue != NULL((void*)0)) |
| 1532 | xmlFree((xmlChar *) (*retValue)); |
| 1533 | if (value2 != NULL((void*)0)) |
| 1534 | xmlFree((xmlChar *) value2); |
| 1535 | return (-1); |
| 1536 | } |
| 1537 | |
| 1538 | /** |
| 1539 | * xmlSchemaFormatItemForReport: |
| 1540 | * @buf: the string buffer |
| 1541 | * @itemDes: the designation of the item |
| 1542 | * @itemName: the name of the item |
| 1543 | * @item: the item as an object |
| 1544 | * @itemNode: the node of the item |
| 1545 | * @local: the local name |
| 1546 | * @parsing: if the function is used during the parse |
| 1547 | * |
| 1548 | * Returns a representation of the given item used |
| 1549 | * for error reports. |
| 1550 | * |
| 1551 | * The following order is used to build the resulting |
| 1552 | * designation if the arguments are not NULL: |
| 1553 | * 1a. If itemDes not NULL -> itemDes |
| 1554 | * 1b. If (itemDes not NULL) and (itemName not NULL) |
| 1555 | * -> itemDes + itemName |
| 1556 | * 2. If the preceding was NULL and (item not NULL) -> item |
| 1557 | * 3. If the preceding was NULL and (itemNode not NULL) -> itemNode |
| 1558 | * |
| 1559 | * If the itemNode is an attribute node, the name of the attribute |
| 1560 | * will be appended to the result. |
| 1561 | * |
| 1562 | * Returns the formatted string and sets @buf to the resulting value. |
| 1563 | */ |
| 1564 | static xmlChar* |
| 1565 | xmlSchemaFormatItemForReport(xmlChar **buf, |
| 1566 | const xmlChar *itemDes, |
| 1567 | xmlSchemaBasicItemPtr item, |
| 1568 | xmlNodePtr itemNode) |
| 1569 | { |
| 1570 | xmlChar *str = NULL((void*)0); |
| 1571 | int named = 1; |
| 1572 | |
| 1573 | if (*buf != NULL((void*)0)) { |
| 1574 | xmlFree(*buf); |
| 1575 | *buf = NULL((void*)0); |
| 1576 | } |
| 1577 | |
| 1578 | if (itemDes != NULL((void*)0)) { |
| 1579 | *buf = xmlStrdup(itemDes); |
| 1580 | } else if (item != NULL((void*)0)) { |
| 1581 | switch (item->type) { |
| 1582 | case XML_SCHEMA_TYPE_BASIC: { |
| 1583 | xmlSchemaTypePtr type = WXS_TYPE_CAST(xmlSchemaTypePtr) item; |
| 1584 | |
| 1585 | if (WXS_IS_ATOMIC(type)(type->flags & 1 << 8)) |
| 1586 | *buf = xmlStrdup(BAD_CAST(xmlChar *) "atomic type 'xs:"); |
| 1587 | else if (WXS_IS_LIST(type)(type->flags & 1 << 6)) |
| 1588 | *buf = xmlStrdup(BAD_CAST(xmlChar *) "list type 'xs:"); |
| 1589 | else if (WXS_IS_UNION(type)(type->flags & 1 << 7)) |
| 1590 | *buf = xmlStrdup(BAD_CAST(xmlChar *) "union type 'xs:"); |
| 1591 | else |
| 1592 | *buf = xmlStrdup(BAD_CAST(xmlChar *) "simple type 'xs:"); |
| 1593 | *buf = xmlStrcat(*buf, type->name); |
| 1594 | *buf = xmlStrcat(*buf, BAD_CAST(xmlChar *) "'"); |
| 1595 | } |
| 1596 | break; |
| 1597 | case XML_SCHEMA_TYPE_SIMPLE: { |
| 1598 | xmlSchemaTypePtr type = WXS_TYPE_CAST(xmlSchemaTypePtr) item; |
| 1599 | |
| 1600 | if (type->flags & XML_SCHEMAS_TYPE_GLOBAL1 << 3) { |
| 1601 | *buf = xmlStrdup(BAD_CAST(xmlChar *)""); |
| 1602 | } else { |
| 1603 | *buf = xmlStrdup(BAD_CAST(xmlChar *) "local "); |
| 1604 | } |
| 1605 | if (WXS_IS_ATOMIC(type)(type->flags & 1 << 8)) |
| 1606 | *buf = xmlStrcat(*buf, BAD_CAST(xmlChar *) "atomic type"); |
| 1607 | else if (WXS_IS_LIST(type)(type->flags & 1 << 6)) |
| 1608 | *buf = xmlStrcat(*buf, BAD_CAST(xmlChar *) "list type"); |
| 1609 | else if (WXS_IS_UNION(type)(type->flags & 1 << 7)) |
| 1610 | *buf = xmlStrcat(*buf, BAD_CAST(xmlChar *) "union type"); |
| 1611 | else |
| 1612 | *buf = xmlStrcat(*buf, BAD_CAST(xmlChar *) "simple type"); |
| 1613 | if (type->flags & XML_SCHEMAS_TYPE_GLOBAL1 << 3) { |
| 1614 | *buf = xmlStrcat(*buf, BAD_CAST(xmlChar *) " '"); |
| 1615 | *buf = xmlStrcat(*buf, type->name); |
| 1616 | *buf = xmlStrcat(*buf, BAD_CAST(xmlChar *) "'"); |
| 1617 | } |
| 1618 | } |
| 1619 | break; |
| 1620 | case XML_SCHEMA_TYPE_COMPLEX: { |
| 1621 | xmlSchemaTypePtr type = WXS_TYPE_CAST(xmlSchemaTypePtr) item; |
| 1622 | |
| 1623 | if (type->flags & XML_SCHEMAS_TYPE_GLOBAL1 << 3) |
| 1624 | *buf = xmlStrdup(BAD_CAST(xmlChar *) ""); |
| 1625 | else |
| 1626 | *buf = xmlStrdup(BAD_CAST(xmlChar *) "local "); |
| 1627 | *buf = xmlStrcat(*buf, BAD_CAST(xmlChar *) "complex type"); |
| 1628 | if (type->flags & XML_SCHEMAS_TYPE_GLOBAL1 << 3) { |
| 1629 | *buf = xmlStrcat(*buf, BAD_CAST(xmlChar *) " '"); |
| 1630 | *buf = xmlStrcat(*buf, type->name); |
| 1631 | *buf = xmlStrcat(*buf, BAD_CAST(xmlChar *) "'"); |
| 1632 | } |
| 1633 | } |
| 1634 | break; |
| 1635 | case XML_SCHEMA_TYPE_ATTRIBUTE_USE: { |
| 1636 | xmlSchemaAttributeUsePtr ause; |
| 1637 | |
| 1638 | ause = WXS_ATTR_USE_CAST(xmlSchemaAttributeUsePtr) item; |
| 1639 | *buf = xmlStrdup(BAD_CAST(xmlChar *) "attribute use "); |
| 1640 | if (WXS_ATTRUSE_DECL(ause)(xmlSchemaAttributePtr) ((xmlSchemaAttributeUsePtr) (ause))-> attrDecl != NULL((void*)0)) { |
| 1641 | *buf = xmlStrcat(*buf, BAD_CAST(xmlChar *) "'"); |
| 1642 | *buf = xmlStrcat(*buf, |
| 1643 | xmlSchemaGetComponentQName(&str, WXS_ATTRUSE_DECL(ause)(xmlSchemaAttributePtr) ((xmlSchemaAttributeUsePtr) (ause))-> attrDecl)); |
| 1644 | FREE_AND_NULL(str)if ((str) != ((void*)0)) { xmlFree((xmlChar *) (str)); str = ( (void*)0); } |
| 1645 | *buf = xmlStrcat(*buf, BAD_CAST(xmlChar *) "'"); |
| 1646 | } else { |
| 1647 | *buf = xmlStrcat(*buf, BAD_CAST(xmlChar *) "(unknown)"); |
| 1648 | } |
| 1649 | } |
| 1650 | break; |
| 1651 | case XML_SCHEMA_TYPE_ATTRIBUTE: { |
| 1652 | xmlSchemaAttributePtr attr; |
| 1653 | |
| 1654 | attr = (xmlSchemaAttributePtr) item; |
| 1655 | *buf = xmlStrdup(BAD_CAST(xmlChar *) "attribute decl."); |
| 1656 | *buf = xmlStrcat(*buf, BAD_CAST(xmlChar *) " '"); |
| 1657 | *buf = xmlStrcat(*buf, xmlSchemaFormatQName(&str, |
| 1658 | attr->targetNamespace, attr->name)); |
| 1659 | FREE_AND_NULL(str)if ((str) != ((void*)0)) { xmlFree((xmlChar *) (str)); str = ( (void*)0); } |
| 1660 | *buf = xmlStrcat(*buf, BAD_CAST(xmlChar *) "'"); |
| 1661 | } |
| 1662 | break; |
| 1663 | case XML_SCHEMA_TYPE_ATTRIBUTEGROUP: |
| 1664 | xmlSchemaGetComponentDesignation(buf, item); |
| 1665 | break; |
| 1666 | case XML_SCHEMA_TYPE_ELEMENT: { |
| 1667 | xmlSchemaElementPtr elem; |
| 1668 | |
| 1669 | elem = (xmlSchemaElementPtr) item; |
| 1670 | *buf = xmlStrdup(BAD_CAST(xmlChar *) "element decl."); |
| 1671 | *buf = xmlStrcat(*buf, BAD_CAST(xmlChar *) " '"); |
| 1672 | *buf = xmlStrcat(*buf, xmlSchemaFormatQName(&str, |
| 1673 | elem->targetNamespace, elem->name)); |
| 1674 | *buf = xmlStrcat(*buf, BAD_CAST(xmlChar *) "'"); |
| 1675 | } |
| 1676 | break; |
| 1677 | case XML_SCHEMA_TYPE_IDC_UNIQUE: |
| 1678 | case XML_SCHEMA_TYPE_IDC_KEY: |
| 1679 | case XML_SCHEMA_TYPE_IDC_KEYREF: |
| 1680 | if (item->type == XML_SCHEMA_TYPE_IDC_UNIQUE) |
| 1681 | *buf = xmlStrdup(BAD_CAST(xmlChar *) "unique '"); |
| 1682 | else if (item->type == XML_SCHEMA_TYPE_IDC_KEY) |
| 1683 | *buf = xmlStrdup(BAD_CAST(xmlChar *) "key '"); |
| 1684 | else |
| 1685 | *buf = xmlStrdup(BAD_CAST(xmlChar *) "keyRef '"); |
| 1686 | *buf = xmlStrcat(*buf, ((xmlSchemaIDCPtr) item)->name); |
| 1687 | *buf = xmlStrcat(*buf, BAD_CAST(xmlChar *) "'"); |
| 1688 | break; |
| 1689 | case XML_SCHEMA_TYPE_ANY: |
| 1690 | case XML_SCHEMA_TYPE_ANY_ATTRIBUTE: |
| 1691 | *buf = xmlStrdup(xmlSchemaWildcardPCToString( |
| 1692 | ((xmlSchemaWildcardPtr) item)->processContents)); |
| 1693 | *buf = xmlStrcat(*buf, BAD_CAST(xmlChar *) " wildcard"); |
| 1694 | break; |
| 1695 | case XML_SCHEMA_FACET_MININCLUSIVE: |
| 1696 | case XML_SCHEMA_FACET_MINEXCLUSIVE: |
| 1697 | case XML_SCHEMA_FACET_MAXINCLUSIVE: |
| 1698 | case XML_SCHEMA_FACET_MAXEXCLUSIVE: |
| 1699 | case XML_SCHEMA_FACET_TOTALDIGITS: |
| 1700 | case XML_SCHEMA_FACET_FRACTIONDIGITS: |
| 1701 | case XML_SCHEMA_FACET_PATTERN: |
| 1702 | case XML_SCHEMA_FACET_ENUMERATION: |
| 1703 | case XML_SCHEMA_FACET_WHITESPACE: |
| 1704 | case XML_SCHEMA_FACET_LENGTH: |
| 1705 | case XML_SCHEMA_FACET_MAXLENGTH: |
| 1706 | case XML_SCHEMA_FACET_MINLENGTH: |
| 1707 | *buf = xmlStrdup(BAD_CAST(xmlChar *) "facet '"); |
| 1708 | *buf = xmlStrcat(*buf, xmlSchemaFacetTypeToString(item->type)); |
| 1709 | *buf = xmlStrcat(*buf, BAD_CAST(xmlChar *) "'"); |
| 1710 | break; |
| 1711 | case XML_SCHEMA_TYPE_GROUP: { |
| 1712 | *buf = xmlStrdup(BAD_CAST(xmlChar *) "model group def."); |
| 1713 | *buf = xmlStrcat(*buf, BAD_CAST(xmlChar *) " '"); |
| 1714 | *buf = xmlStrcat(*buf, xmlSchemaGetComponentQName(&str, item)); |
| 1715 | *buf = xmlStrcat(*buf, BAD_CAST(xmlChar *) "'"); |
| 1716 | FREE_AND_NULL(str)if ((str) != ((void*)0)) { xmlFree((xmlChar *) (str)); str = ( (void*)0); } |
| 1717 | } |
| 1718 | break; |
| 1719 | case XML_SCHEMA_TYPE_SEQUENCE: |
| 1720 | case XML_SCHEMA_TYPE_CHOICE: |
| 1721 | case XML_SCHEMA_TYPE_ALL: |
| 1722 | case XML_SCHEMA_TYPE_PARTICLE: |
| 1723 | *buf = xmlStrdup(WXS_ITEM_TYPE_NAME(item)xmlSchemaGetComponentTypeStr((xmlSchemaBasicItemPtr) (item))); |
| 1724 | break; |
| 1725 | case XML_SCHEMA_TYPE_NOTATION: { |
| 1726 | *buf = xmlStrdup(WXS_ITEM_TYPE_NAME(item)xmlSchemaGetComponentTypeStr((xmlSchemaBasicItemPtr) (item))); |
| 1727 | *buf = xmlStrcat(*buf, BAD_CAST(xmlChar *) " '"); |
| 1728 | *buf = xmlStrcat(*buf, xmlSchemaGetComponentQName(&str, item)); |
| 1729 | *buf = xmlStrcat(*buf, BAD_CAST(xmlChar *) "'"); |
| 1730 | FREE_AND_NULL(str)if ((str) != ((void*)0)) { xmlFree((xmlChar *) (str)); str = ( (void*)0); }; |
| 1731 | } |
| 1732 | default: |
| 1733 | named = 0; |
| 1734 | } |
| 1735 | } else |
| 1736 | named = 0; |
| 1737 | |
| 1738 | if ((named == 0) && (itemNode != NULL((void*)0))) { |
| 1739 | xmlNodePtr elem; |
| 1740 | |
| 1741 | if (itemNode->type == XML_ATTRIBUTE_NODE) |
| 1742 | elem = itemNode->parent; |
| 1743 | else |
| 1744 | elem = itemNode; |
| 1745 | *buf = xmlStrdup(BAD_CAST(xmlChar *) "Element '"); |
| 1746 | if (elem->ns != NULL((void*)0)) { |
| 1747 | *buf = xmlStrcat(*buf, |
| 1748 | xmlSchemaFormatQName(&str, elem->ns->href, elem->name)); |
| 1749 | FREE_AND_NULL(str)if ((str) != ((void*)0)) { xmlFree((xmlChar *) (str)); str = ( (void*)0); } |
| 1750 | } else |
| 1751 | *buf = xmlStrcat(*buf, elem->name); |
| 1752 | *buf = xmlStrcat(*buf, BAD_CAST(xmlChar *) "'"); |
| 1753 | |
| 1754 | } |
| 1755 | if ((itemNode != NULL((void*)0)) && (itemNode->type == XML_ATTRIBUTE_NODE)) { |
| 1756 | *buf = xmlStrcat(*buf, BAD_CAST(xmlChar *) ", attribute '"); |
| 1757 | if (itemNode->ns != NULL((void*)0)) { |
| 1758 | *buf = xmlStrcat(*buf, xmlSchemaFormatQName(&str, |
| 1759 | itemNode->ns->href, itemNode->name)); |
| 1760 | FREE_AND_NULL(str)if ((str) != ((void*)0)) { xmlFree((xmlChar *) (str)); str = ( (void*)0); } |
| 1761 | } else |
| 1762 | *buf = xmlStrcat(*buf, itemNode->name); |
| 1763 | *buf = xmlStrcat(*buf, BAD_CAST(xmlChar *) "'"); |
| 1764 | } |
| 1765 | FREE_AND_NULL(str)if ((str) != ((void*)0)) { xmlFree((xmlChar *) (str)); str = ( (void*)0); } |
| 1766 | |
| 1767 | return (*buf); |
| 1768 | } |
| 1769 | |
| 1770 | /** |
| 1771 | * xmlSchemaFormatFacetEnumSet: |
| 1772 | * @buf: the string buffer |
| 1773 | * @type: the type holding the enumeration facets |
| 1774 | * |
| 1775 | * Builds a string consisting of all enumeration elements. |
| 1776 | * |
| 1777 | * Returns a string of all enumeration elements. |
| 1778 | */ |
| 1779 | static const xmlChar * |
| 1780 | xmlSchemaFormatFacetEnumSet(xmlSchemaAbstractCtxtPtr actxt, |
| 1781 | xmlChar **buf, xmlSchemaTypePtr type) |
| 1782 | { |
| 1783 | xmlSchemaFacetPtr facet; |
| 1784 | xmlSchemaWhitespaceValueType ws; |
| 1785 | xmlChar *value = NULL((void*)0); |
| 1786 | int res, found = 0; |
| 1787 | |
| 1788 | if (*buf != NULL((void*)0)) |
| 1789 | xmlFree(*buf); |
| 1790 | *buf = NULL((void*)0); |
| 1791 | |
| 1792 | do { |
| 1793 | /* |
| 1794 | * Use the whitespace type of the base type. |
| 1795 | */ |
| 1796 | ws = xmlSchemaGetWhiteSpaceFacetValue(type->baseType); |
| 1797 | for (facet = type->facets; facet != NULL((void*)0); facet = facet->next) { |
| 1798 | if (facet->type != XML_SCHEMA_FACET_ENUMERATION) |
| 1799 | continue; |
| 1800 | found = 1; |
| 1801 | res = xmlSchemaGetCanonValueWhtspExt(facet->val, |
| 1802 | ws, &value); |
| 1803 | if (res == -1) { |
| 1804 | xmlSchemaInternalErr(actxt, |
| 1805 | "xmlSchemaFormatFacetEnumSet", |
| 1806 | "compute the canonical lexical representation"); |
| 1807 | if (*buf != NULL((void*)0)) |
| 1808 | xmlFree(*buf); |
| 1809 | *buf = NULL((void*)0); |
| 1810 | return (NULL((void*)0)); |
| 1811 | } |
| 1812 | if (*buf == NULL((void*)0)) |
| 1813 | *buf = xmlStrdup(BAD_CAST(xmlChar *) "'"); |
| 1814 | else |
| 1815 | *buf = xmlStrcat(*buf, BAD_CAST(xmlChar *) ", '"); |
| 1816 | *buf = xmlStrcat(*buf, BAD_CAST(xmlChar *) value); |
| 1817 | *buf = xmlStrcat(*buf, BAD_CAST(xmlChar *) "'"); |
| 1818 | if (value != NULL((void*)0)) { |
| 1819 | xmlFree((xmlChar *)value); |
| 1820 | value = NULL((void*)0); |
| 1821 | } |
| 1822 | } |
| 1823 | /* |
| 1824 | * The enumeration facet of a type restricts the enumeration |
| 1825 | * facet of the ancestor type; i.e., such restricted enumerations |
| 1826 | * do not belong to the set of the given type. Thus we break |
| 1827 | * on the first found enumeration. |
| 1828 | */ |
| 1829 | if (found) |
| 1830 | break; |
| 1831 | type = type->baseType; |
| 1832 | } while ((type != NULL((void*)0)) && (type->type != XML_SCHEMA_TYPE_BASIC)); |
| 1833 | |
| 1834 | return ((const xmlChar *) *buf); |
| 1835 | } |
| 1836 | |
| 1837 | /************************************************************************ |
| 1838 | * * |
| 1839 | * Error functions * |
| 1840 | * * |
| 1841 | ************************************************************************/ |
| 1842 | |
| 1843 | #if 0 |
| 1844 | static void |
| 1845 | xmlSchemaErrMemory(const char *msg) |
| 1846 | { |
| 1847 | __xmlSimpleError(XML_FROM_SCHEMASP, XML_ERR_NO_MEMORY, NULL((void*)0), NULL((void*)0), |
| 1848 | msg); |
| 1849 | } |
| 1850 | #endif |
| 1851 | |
| 1852 | static void |
| 1853 | xmlSchemaPSimpleErr(const char *msg) |
| 1854 | { |
| 1855 | __xmlSimpleError(XML_FROM_SCHEMASP, XML_ERR_NO_MEMORY, NULL((void*)0), NULL((void*)0), |
| 1856 | msg); |
| 1857 | } |
| 1858 | |
| 1859 | /** |
| 1860 | * xmlSchemaPErrMemory: |
| 1861 | * @node: a context node |
| 1862 | * @extra: extra informations |
| 1863 | * |
| 1864 | * Handle an out of memory condition |
| 1865 | */ |
| 1866 | static void |
| 1867 | xmlSchemaPErrMemory(xmlSchemaParserCtxtPtr ctxt, |
| 1868 | const char *extra, xmlNodePtr node) |
| 1869 | { |
| 1870 | if (ctxt != NULL((void*)0)) |
| 1871 | ctxt->nberrors++; |
| 1872 | __xmlSimpleError(XML_FROM_SCHEMASP, XML_ERR_NO_MEMORY, node, NULL((void*)0), |
| 1873 | extra); |
| 1874 | } |
| 1875 | |
| 1876 | /** |
| 1877 | * xmlSchemaPErr: |
| 1878 | * @ctxt: the parsing context |
| 1879 | * @node: the context node |
| 1880 | * @error: the error code |
| 1881 | * @msg: the error message |
| 1882 | * @str1: extra data |
| 1883 | * @str2: extra data |
| 1884 | * |
| 1885 | * Handle a parser error |
| 1886 | */ |
| 1887 | static void |
| 1888 | xmlSchemaPErr(xmlSchemaParserCtxtPtr ctxt, xmlNodePtr node, int error, |
| 1889 | const char *msg, const xmlChar * str1, const xmlChar * str2) |
| 1890 | { |
| 1891 | xmlGenericErrorFunc channel = NULL((void*)0); |
| 1892 | xmlStructuredErrorFunc schannel = NULL((void*)0); |
| 1893 | void *data = NULL((void*)0); |
| 1894 | |
| 1895 | if (ctxt != NULL((void*)0)) { |
| 1896 | ctxt->nberrors++; |
| 1897 | ctxt->err = error; |
| 1898 | channel = ctxt->error; |
| 1899 | data = ctxt->errCtxt; |
| 1900 | schannel = ctxt->serror; |
| 1901 | } |
| 1902 | __xmlRaiseError(schannel, channel, data, ctxt, node, XML_FROM_SCHEMASP, |
| 1903 | error, XML_ERR_ERROR, NULL((void*)0), 0, |
| 1904 | (const char *) str1, (const char *) str2, NULL((void*)0), 0, 0, |
| 1905 | msg, str1, str2); |
| 1906 | } |
| 1907 | |
| 1908 | /** |
| 1909 | * xmlSchemaPErr2: |
| 1910 | * @ctxt: the parsing context |
| 1911 | * @node: the context node |
| 1912 | * @node: the current child |
| 1913 | * @error: the error code |
| 1914 | * @msg: the error message |
| 1915 | * @str1: extra data |
| 1916 | * @str2: extra data |
| 1917 | * |
| 1918 | * Handle a parser error |
| 1919 | */ |
| 1920 | static void |
| 1921 | xmlSchemaPErr2(xmlSchemaParserCtxtPtr ctxt, xmlNodePtr node, |
| 1922 | xmlNodePtr child, int error, |
| 1923 | const char *msg, const xmlChar * str1, const xmlChar * str2) |
| 1924 | { |
| 1925 | if (child != NULL((void*)0)) |
| 1926 | xmlSchemaPErr(ctxt, child, error, msg, str1, str2); |
| 1927 | else |
| 1928 | xmlSchemaPErr(ctxt, node, error, msg, str1, str2); |
| 1929 | } |
| 1930 | |
| 1931 | |
| 1932 | /** |
| 1933 | * xmlSchemaPErrExt: |
| 1934 | * @ctxt: the parsing context |
| 1935 | * @node: the context node |
| 1936 | * @error: the error code |
| 1937 | * @strData1: extra data |
| 1938 | * @strData2: extra data |
| 1939 | * @strData3: extra data |
| 1940 | * @msg: the message |
| 1941 | * @str1: extra parameter for the message display |
| 1942 | * @str2: extra parameter for the message display |
| 1943 | * @str3: extra parameter for the message display |
| 1944 | * @str4: extra parameter for the message display |
| 1945 | * @str5: extra parameter for the message display |
| 1946 | * |
| 1947 | * Handle a parser error |
| 1948 | */ |
| 1949 | static void |
| 1950 | xmlSchemaPErrExt(xmlSchemaParserCtxtPtr ctxt, xmlNodePtr node, int error, |
| 1951 | const xmlChar * strData1, const xmlChar * strData2, |
| 1952 | const xmlChar * strData3, const char *msg, const xmlChar * str1, |
| 1953 | const xmlChar * str2, const xmlChar * str3, const xmlChar * str4, |
| 1954 | const xmlChar * str5) |
| 1955 | { |
| 1956 | |
| 1957 | xmlGenericErrorFunc channel = NULL((void*)0); |
| 1958 | xmlStructuredErrorFunc schannel = NULL((void*)0); |
| 1959 | void *data = NULL((void*)0); |
| 1960 | |
| 1961 | if (ctxt != NULL((void*)0)) { |
| 1962 | ctxt->nberrors++; |
| 1963 | ctxt->err = error; |
| 1964 | channel = ctxt->error; |
| 1965 | data = ctxt->errCtxt; |
| 1966 | schannel = ctxt->serror; |
| 1967 | } |
| 1968 | __xmlRaiseError(schannel, channel, data, ctxt, node, XML_FROM_SCHEMASP, |
| 1969 | error, XML_ERR_ERROR, NULL((void*)0), 0, |
| 1970 | (const char *) strData1, (const char *) strData2, |
| 1971 | (const char *) strData3, 0, 0, msg, str1, str2, |
| 1972 | str3, str4, str5); |
| 1973 | } |
| 1974 | |
| 1975 | /************************************************************************ |
| 1976 | * * |
| 1977 | * Allround error functions * |
| 1978 | * * |
| 1979 | ************************************************************************/ |
| 1980 | |
| 1981 | /** |
| 1982 | * xmlSchemaVTypeErrMemory: |
| 1983 | * @node: a context node |
| 1984 | * @extra: extra informations |
| 1985 | * |
| 1986 | * Handle an out of memory condition |
| 1987 | */ |
| 1988 | static void |
| 1989 | xmlSchemaVErrMemory(xmlSchemaValidCtxtPtr ctxt, |
| 1990 | const char *extra, xmlNodePtr node) |
| 1991 | { |
| 1992 | if (ctxt != NULL((void*)0)) { |
| 1993 | ctxt->nberrors++; |
| 1994 | ctxt->err = XML_SCHEMAV_INTERNAL; |
| 1995 | } |
| 1996 | __xmlSimpleError(XML_FROM_SCHEMASV, XML_ERR_NO_MEMORY, node, NULL((void*)0), |
| 1997 | extra); |
| 1998 | } |
| 1999 | |
| 2000 | static void |
| 2001 | xmlSchemaPSimpleInternalErr(xmlNodePtr node, |
| 2002 | const char *msg, const xmlChar *str) |
| 2003 | { |
| 2004 | __xmlSimpleError(XML_FROM_SCHEMASP, XML_SCHEMAP_INTERNAL, node, |
| 2005 | msg, (const char *) str); |
| 2006 | } |
| 2007 | |
| 2008 | #define WXS_ERROR_TYPE_ERROR1 1 |
| 2009 | #define WXS_ERROR_TYPE_WARNING2 2 |
| 2010 | /** |
| 2011 | * xmlSchemaErr3: |
| 2012 | * @ctxt: the validation context |
| 2013 | * @node: the context node |
| 2014 | * @error: the error code |
| 2015 | * @msg: the error message |
| 2016 | * @str1: extra data |
| 2017 | * @str2: extra data |
| 2018 | * @str3: extra data |
| 2019 | * |
| 2020 | * Handle a validation error |
| 2021 | */ |
| 2022 | static void |
| 2023 | xmlSchemaErr4Line(xmlSchemaAbstractCtxtPtr ctxt, |
| 2024 | xmlErrorLevel errorLevel, |
| 2025 | int error, xmlNodePtr node, int line, const char *msg, |
| 2026 | const xmlChar *str1, const xmlChar *str2, |
| 2027 | const xmlChar *str3, const xmlChar *str4) |
| 2028 | { |
| 2029 | xmlStructuredErrorFunc schannel = NULL((void*)0); |
| 2030 | xmlGenericErrorFunc channel = NULL((void*)0); |
| 2031 | void *data = NULL((void*)0); |
| 2032 | |
| 2033 | if (ctxt != NULL((void*)0)) { |
| 2034 | if (ctxt->type == XML_SCHEMA_CTXT_VALIDATOR2) { |
| 2035 | xmlSchemaValidCtxtPtr vctxt = (xmlSchemaValidCtxtPtr) ctxt; |
| 2036 | const char *file = NULL((void*)0); |
| 2037 | if (errorLevel != XML_ERR_WARNING) { |
| 2038 | vctxt->nberrors++; |
| 2039 | vctxt->err = error; |
| 2040 | channel = vctxt->error; |
| 2041 | } else { |
| 2042 | channel = vctxt->warning; |
| 2043 | } |
| 2044 | schannel = vctxt->serror; |
| 2045 | data = vctxt->errCtxt; |
| 2046 | |
| 2047 | /* |
| 2048 | * Error node. If we specify a line number, then |
| 2049 | * do not channel any node to the error function. |
| 2050 | */ |
| 2051 | if (line == 0) { |
| 2052 | if ((node == NULL((void*)0)) && |
| 2053 | (vctxt->depth >= 0) && |
| 2054 | (vctxt->inode != NULL((void*)0))) { |
| 2055 | node = vctxt->inode->node; |
| 2056 | } |
| 2057 | /* |
| 2058 | * Get filename and line if no node-tree. |
| 2059 | */ |
| 2060 | if ((node == NULL((void*)0)) && |
| 2061 | (vctxt->parserCtxt != NULL((void*)0)) && |
| 2062 | (vctxt->parserCtxt->input != NULL((void*)0))) { |
| 2063 | file = vctxt->parserCtxt->input->filename; |
| 2064 | line = vctxt->parserCtxt->input->line; |
| 2065 | } |
| 2066 | } else { |
| 2067 | /* |
| 2068 | * Override the given node's (if any) position |
| 2069 | * and channel only the given line number. |
| 2070 | */ |
| 2071 | node = NULL((void*)0); |
| 2072 | /* |
| 2073 | * Get filename. |
| 2074 | */ |
| 2075 | if (vctxt->doc != NULL((void*)0)) |
| 2076 | file = (const char *) vctxt->doc->URL; |
| 2077 | else if ((vctxt->parserCtxt != NULL((void*)0)) && |
| 2078 | (vctxt->parserCtxt->input != NULL((void*)0))) |
| 2079 | file = vctxt->parserCtxt->input->filename; |
| 2080 | } |
| 2081 | __xmlRaiseError(schannel, channel, data, ctxt, |
| 2082 | node, XML_FROM_SCHEMASV, |
| 2083 | error, errorLevel, file, line, |
| 2084 | (const char *) str1, (const char *) str2, |
| 2085 | (const char *) str3, 0, 0, msg, str1, str2, str3, str4); |
| 2086 | |
| 2087 | } else if (ctxt->type == XML_SCHEMA_CTXT_PARSER1) { |
| 2088 | xmlSchemaParserCtxtPtr pctxt = (xmlSchemaParserCtxtPtr) ctxt; |
| 2089 | if (errorLevel != XML_ERR_WARNING) { |
| 2090 | pctxt->nberrors++; |
| 2091 | pctxt->err = error; |
| 2092 | channel = pctxt->error; |
| 2093 | } else { |
| 2094 | channel = pctxt->warning; |
| 2095 | } |
| 2096 | schannel = pctxt->serror; |
| 2097 | data = pctxt->errCtxt; |
| 2098 | __xmlRaiseError(schannel, channel, data, ctxt, |
| 2099 | node, XML_FROM_SCHEMASP, error, |
| 2100 | errorLevel, NULL((void*)0), 0, |
| 2101 | (const char *) str1, (const char *) str2, |
| 2102 | (const char *) str3, 0, 0, msg, str1, str2, str3, str4); |
| 2103 | } else { |
| 2104 | TODO(*(__xmlGenericError()))((*(__xmlGenericErrorContext())), "Unimplemented block at %s:%d\n" , "xmlschemas.c", 2104); |
| 2105 | } |
| 2106 | } |
| 2107 | } |
| 2108 | |
| 2109 | /** |
| 2110 | * xmlSchemaErr3: |
| 2111 | * @ctxt: the validation context |
| 2112 | * @node: the context node |
| 2113 | * @error: the error code |
| 2114 | * @msg: the error message |
| 2115 | * @str1: extra data |
| 2116 | * @str2: extra data |
| 2117 | * @str3: extra data |
| 2118 | * |
| 2119 | * Handle a validation error |
| 2120 | */ |
| 2121 | static void |
| 2122 | xmlSchemaErr3(xmlSchemaAbstractCtxtPtr actxt, |
| 2123 | int error, xmlNodePtr node, const char *msg, |
| 2124 | const xmlChar *str1, const xmlChar *str2, const xmlChar *str3) |
| 2125 | { |
| 2126 | xmlSchemaErr4Line(actxt, XML_ERR_ERROR, error, node, 0, |
| 2127 | msg, str1, str2, str3, NULL((void*)0)); |
| 2128 | } |
| 2129 | |
| 2130 | static void |
| 2131 | xmlSchemaErr4(xmlSchemaAbstractCtxtPtr actxt, |
| 2132 | int error, xmlNodePtr node, const char *msg, |
| 2133 | const xmlChar *str1, const xmlChar *str2, |
| 2134 | const xmlChar *str3, const xmlChar *str4) |
| 2135 | { |
| 2136 | xmlSchemaErr4Line(actxt, XML_ERR_ERROR, error, node, 0, |
| 2137 | msg, str1, str2, str3, str4); |
| 2138 | } |
| 2139 | |
| 2140 | static void |
| 2141 | xmlSchemaErr(xmlSchemaAbstractCtxtPtr actxt, |
| 2142 | int error, xmlNodePtr node, const char *msg, |
| 2143 | const xmlChar *str1, const xmlChar *str2) |
| 2144 | { |
| 2145 | xmlSchemaErr4(actxt, error, node, msg, str1, str2, NULL((void*)0), NULL((void*)0)); |
| 2146 | } |
| 2147 | |
| 2148 | static xmlChar * |
| 2149 | xmlSchemaFormatNodeForError(xmlChar ** msg, |
| 2150 | xmlSchemaAbstractCtxtPtr actxt, |
| 2151 | xmlNodePtr node) |
| 2152 | { |
| 2153 | xmlChar *str = NULL((void*)0); |
| 2154 | |
| 2155 | *msg = NULL((void*)0); |
| 2156 | if ((node != NULL((void*)0)) && |
| 2157 | (node->type != XML_ELEMENT_NODE) && |
| 2158 | (node->type != XML_ATTRIBUTE_NODE)) |
| 2159 | { |
| 2160 | /* |
| 2161 | * Don't try to format other nodes than element and |
| 2162 | * attribute nodes. |
| 2163 | * Play save and return an empty string. |
| 2164 | */ |
| 2165 | *msg = xmlStrdup(BAD_CAST(xmlChar *) ""); |
| 2166 | return(*msg); |
| 2167 | } |
| 2168 | if (node != NULL((void*)0)) { |
| 2169 | /* |
| 2170 | * Work on tree nodes. |
| 2171 | */ |
| 2172 | if (node->type == XML_ATTRIBUTE_NODE) { |
| 2173 | xmlNodePtr elem = node->parent; |
| 2174 | |
| 2175 | *msg = xmlStrdup(BAD_CAST(xmlChar *) "Element '"); |
| 2176 | if (elem->ns != NULL((void*)0)) |
| 2177 | *msg = xmlStrcat(*msg, xmlSchemaFormatQName(&str, |
| 2178 | elem->ns->href, elem->name)); |
| 2179 | else |
| 2180 | *msg = xmlStrcat(*msg, xmlSchemaFormatQName(&str, |
| 2181 | NULL((void*)0), elem->name)); |
| 2182 | FREE_AND_NULL(str)if ((str) != ((void*)0)) { xmlFree((xmlChar *) (str)); str = ( (void*)0); }; |
| 2183 | *msg = xmlStrcat(*msg, BAD_CAST(xmlChar *) "', "); |
| 2184 | *msg = xmlStrcat(*msg, BAD_CAST(xmlChar *) "attribute '"); |
| 2185 | } else { |
| 2186 | *msg = xmlStrdup(BAD_CAST(xmlChar *) "Element '"); |
| 2187 | } |
| 2188 | if (node->ns != NULL((void*)0)) |
| 2189 | *msg = xmlStrcat(*msg, xmlSchemaFormatQName(&str, |
| 2190 | node->ns->href, node->name)); |
| 2191 | else |
| 2192 | *msg = xmlStrcat(*msg, xmlSchemaFormatQName(&str, |
| 2193 | NULL((void*)0), node->name)); |
| 2194 | FREE_AND_NULL(str)if ((str) != ((void*)0)) { xmlFree((xmlChar *) (str)); str = ( (void*)0); }; |
| 2195 | *msg = xmlStrcat(*msg, BAD_CAST(xmlChar *) "': "); |
| 2196 | } else if (actxt->type == XML_SCHEMA_CTXT_VALIDATOR2) { |
| 2197 | xmlSchemaValidCtxtPtr vctxt = (xmlSchemaValidCtxtPtr) actxt; |
| 2198 | /* |
| 2199 | * Work on node infos. |
| 2200 | */ |
| 2201 | if (vctxt->inode->nodeType == XML_ATTRIBUTE_NODE) { |
| 2202 | xmlSchemaNodeInfoPtr ielem = |
| 2203 | vctxt->elemInfos[vctxt->depth]; |
| 2204 | |
| 2205 | *msg = xmlStrdup(BAD_CAST(xmlChar *) "Element '"); |
| 2206 | *msg = xmlStrcat(*msg, xmlSchemaFormatQName(&str, |
| 2207 | ielem->nsName, ielem->localName)); |
| 2208 | FREE_AND_NULL(str)if ((str) != ((void*)0)) { xmlFree((xmlChar *) (str)); str = ( (void*)0); }; |
| 2209 | *msg = xmlStrcat(*msg, BAD_CAST(xmlChar *) "', "); |
| 2210 | *msg = xmlStrcat(*msg, BAD_CAST(xmlChar *) "attribute '"); |
| 2211 | } else { |
| 2212 | *msg = xmlStrdup(BAD_CAST(xmlChar *) "Element '"); |
| 2213 | } |
| 2214 | *msg = xmlStrcat(*msg, xmlSchemaFormatQName(&str, |
| 2215 | vctxt->inode->nsName, vctxt->inode->localName)); |
| 2216 | FREE_AND_NULL(str)if ((str) != ((void*)0)) { xmlFree((xmlChar *) (str)); str = ( (void*)0); }; |
| 2217 | *msg = xmlStrcat(*msg, BAD_CAST(xmlChar *) "': "); |
| 2218 | } else if (actxt->type == XML_SCHEMA_CTXT_PARSER1) { |
| 2219 | /* |
| 2220 | * Hmm, no node while parsing? |
| 2221 | * Return an empty string, in case NULL will break something. |
| 2222 | */ |
| 2223 | *msg = xmlStrdup(BAD_CAST(xmlChar *) ""); |
| 2224 | } else { |
| 2225 | TODO(*(__xmlGenericError()))((*(__xmlGenericErrorContext())), "Unimplemented block at %s:%d\n" , "xmlschemas.c", 2225); |
| 2226 | return (NULL((void*)0)); |
| 2227 | } |
| 2228 | /* |
| 2229 | * VAL TODO: The output of the given schema component is currently |
| 2230 | * disabled. |
| 2231 | */ |
| 2232 | #if 0 |
| 2233 | if ((type != NULL((void*)0)) && (xmlSchemaIsGlobalItem(type))) { |
| 2234 | *msg = xmlStrcat(*msg, BAD_CAST(xmlChar *) " ["); |
| 2235 | *msg = xmlStrcat(*msg, xmlSchemaFormatItemForReport(&str, |
| 2236 | NULL((void*)0), type, NULL((void*)0), 0)); |
| 2237 | FREE_AND_NULL(str)if ((str) != ((void*)0)) { xmlFree((xmlChar *) (str)); str = ( (void*)0); } |
| 2238 | *msg = xmlStrcat(*msg, BAD_CAST(xmlChar *) "]"); |
| 2239 | } |
| 2240 | #endif |
| 2241 | return (*msg); |
| 2242 | } |
| 2243 | |
| 2244 | static void |
| 2245 | xmlSchemaInternalErr2(xmlSchemaAbstractCtxtPtr actxt, |
| 2246 | const char *funcName, |
| 2247 | const char *message, |
| 2248 | const xmlChar *str1, |
| 2249 | const xmlChar *str2) |
| 2250 | { |
| 2251 | xmlChar *msg = NULL((void*)0); |
| 2252 | |
| 2253 | if (actxt == NULL((void*)0)) |
| 2254 | return; |
| 2255 | msg = xmlStrdup(BAD_CAST(xmlChar *) "Internal error: "); |
| 2256 | msg = xmlStrcat(msg, BAD_CAST(xmlChar *) funcName); |
| 2257 | msg = xmlStrcat(msg, BAD_CAST(xmlChar *) ", "); |
| 2258 | msg = xmlStrcat(msg, BAD_CAST(xmlChar *) message); |
| 2259 | msg = xmlStrcat(msg, BAD_CAST(xmlChar *) ".\n"); |
| 2260 | |
| 2261 | if (actxt->type == XML_SCHEMA_CTXT_VALIDATOR2) |
| 2262 | xmlSchemaErr(actxt, XML_SCHEMAV_INTERNAL, NULL((void*)0), |
| 2263 | (const char *) msg, str1, str2); |
| 2264 | |
| 2265 | else if (actxt->type == XML_SCHEMA_CTXT_PARSER1) |
| 2266 | xmlSchemaErr(actxt, XML_SCHEMAP_INTERNAL, NULL((void*)0), |
| 2267 | (const char *) msg, str1, str2); |
| 2268 | |
| 2269 | FREE_AND_NULL(msg)if ((msg) != ((void*)0)) { xmlFree((xmlChar *) (msg)); msg = ( (void*)0); } |
| 2270 | } |
| 2271 | |
| 2272 | static void |
| 2273 | xmlSchemaInternalErr(xmlSchemaAbstractCtxtPtr actxt, |
| 2274 | const char *funcName, |
| 2275 | const char *message) |
| 2276 | { |
| 2277 | xmlSchemaInternalErr2(actxt, funcName, message, NULL((void*)0), NULL((void*)0)); |
| 2278 | } |
| 2279 | |
| 2280 | #if 0 |
| 2281 | static void |
| 2282 | xmlSchemaPInternalErr(xmlSchemaParserCtxtPtr pctxt, |
| 2283 | const char *funcName, |
| 2284 | const char *message, |
| 2285 | const xmlChar *str1, |
| 2286 | const xmlChar *str2) |
| 2287 | { |
| 2288 | xmlSchemaInternalErr2(ACTXT_CAST(xmlSchemaAbstractCtxtPtr) pctxt, funcName, message, |
| 2289 | str1, str2); |
| 2290 | } |
| 2291 | #endif |
| 2292 | |
| 2293 | static void |
| 2294 | xmlSchemaCustomErr4(xmlSchemaAbstractCtxtPtr actxt, |
| 2295 | xmlParserErrors error, |
| 2296 | xmlNodePtr node, |
| 2297 | xmlSchemaBasicItemPtr item, |
| 2298 | const char *message, |
| 2299 | const xmlChar *str1, const xmlChar *str2, |
| 2300 | const xmlChar *str3, const xmlChar *str4) |
| 2301 | { |
| 2302 | xmlChar *msg = NULL((void*)0); |
| 2303 | |
| 2304 | if ((node == NULL((void*)0)) && (item != NULL((void*)0)) && |
| 2305 | (actxt->type == XML_SCHEMA_CTXT_PARSER1)) { |
| 2306 | node = WXS_ITEM_NODE(item)xmlSchemaGetComponentNode((xmlSchemaBasicItemPtr) (item)); |
| 2307 | xmlSchemaFormatItemForReport(&msg, NULL((void*)0), item, NULL((void*)0)); |
| 2308 | msg = xmlStrcat(msg, BAD_CAST(xmlChar *) ": "); |
| 2309 | } else |
| 2310 | xmlSchemaFormatNodeForError(&msg, actxt, node); |
| 2311 | msg = xmlStrcat(msg, (const xmlChar *) message); |
| 2312 | msg = xmlStrcat(msg, BAD_CAST(xmlChar *) ".\n"); |
| 2313 | xmlSchemaErr4(actxt, error, node, |
| 2314 | (const char *) msg, str1, str2, str3, str4); |
| 2315 | FREE_AND_NULL(msg)if ((msg) != ((void*)0)) { xmlFree((xmlChar *) (msg)); msg = ( (void*)0); } |
| 2316 | } |
| 2317 | |
| 2318 | static void |
| 2319 | xmlSchemaCustomErr(xmlSchemaAbstractCtxtPtr actxt, |
| 2320 | xmlParserErrors error, |
| 2321 | xmlNodePtr node, |
| 2322 | xmlSchemaBasicItemPtr item, |
| 2323 | const char *message, |
| 2324 | const xmlChar *str1, |
| 2325 | const xmlChar *str2) |
| 2326 | { |
| 2327 | xmlSchemaCustomErr4(actxt, error, node, item, |
| 2328 | message, str1, str2, NULL((void*)0), NULL((void*)0)); |
| 2329 | } |
| 2330 | |
| 2331 | |
| 2332 | |
| 2333 | static void |
| 2334 | xmlSchemaCustomWarning(xmlSchemaAbstractCtxtPtr actxt, |
| 2335 | xmlParserErrors error, |
| 2336 | xmlNodePtr node, |
| 2337 | xmlSchemaTypePtr type ATTRIBUTE_UNUSED__attribute__((unused)), |
| 2338 | const char *message, |
| 2339 | const xmlChar *str1, |
| 2340 | const xmlChar *str2, |
| 2341 | const xmlChar *str3) |
| 2342 | { |
| 2343 | xmlChar *msg = NULL((void*)0); |
| 2344 | |
| 2345 | xmlSchemaFormatNodeForError(&msg, actxt, node); |
| 2346 | msg = xmlStrcat(msg, (const xmlChar *) message); |
| 2347 | msg = xmlStrcat(msg, BAD_CAST(xmlChar *) ".\n"); |
| 2348 | |
| 2349 | /* URGENT TODO: Set the error code to something sane. */ |
| 2350 | xmlSchemaErr4Line(actxt, XML_ERR_WARNING, error, node, 0, |
| 2351 | (const char *) msg, str1, str2, str3, NULL((void*)0)); |
| 2352 | |
| 2353 | FREE_AND_NULL(msg)if ((msg) != ((void*)0)) { xmlFree((xmlChar *) (msg)); msg = ( (void*)0); } |
| 2354 | } |
| 2355 | |
| 2356 | |
| 2357 | |
| 2358 | static void |
| 2359 | xmlSchemaKeyrefErr(xmlSchemaValidCtxtPtr vctxt, |
| 2360 | xmlParserErrors error, |
| 2361 | xmlSchemaPSVIIDCNodePtr idcNode, |
| 2362 | xmlSchemaTypePtr type ATTRIBUTE_UNUSED__attribute__((unused)), |
| 2363 | const char *message, |
| 2364 | const xmlChar *str1, |
| 2365 | const xmlChar *str2) |
| 2366 | { |
| 2367 | xmlChar *msg = NULL((void*)0), *qname = NULL((void*)0); |
| 2368 | |
| 2369 | msg = xmlStrdup(BAD_CAST(xmlChar *) "Element '%s': "); |
| 2370 | msg = xmlStrcat(msg, (const xmlChar *) message); |
| 2371 | msg = xmlStrcat(msg, BAD_CAST(xmlChar *) ".\n"); |
| 2372 | xmlSchemaErr4Line(ACTXT_CAST(xmlSchemaAbstractCtxtPtr) vctxt, XML_ERR_ERROR, |
| 2373 | error, NULL((void*)0), idcNode->nodeLine, (const char *) msg, |
| 2374 | xmlSchemaFormatQName(&qname, |
| 2375 | vctxt->nodeQNames->items[idcNode->nodeQNameID +1], |
| 2376 | vctxt->nodeQNames->items[idcNode->nodeQNameID]), |
| 2377 | str1, str2, NULL((void*)0)); |
| 2378 | FREE_AND_NULL(qname)if ((qname) != ((void*)0)) { xmlFree((xmlChar *) (qname)); qname = ((void*)0); }; |
| 2379 | FREE_AND_NULL(msg)if ((msg) != ((void*)0)) { xmlFree((xmlChar *) (msg)); msg = ( (void*)0); }; |
| 2380 | } |
| 2381 | |
| 2382 | static int |
| 2383 | xmlSchemaEvalErrorNodeType(xmlSchemaAbstractCtxtPtr actxt, |
| 2384 | xmlNodePtr node) |
| 2385 | { |
| 2386 | if (node != NULL((void*)0)) |
| 2387 | return (node->type); |
| 2388 | if ((actxt->type == XML_SCHEMA_CTXT_VALIDATOR2) && |
| 2389 | (((xmlSchemaValidCtxtPtr) actxt)->inode != NULL((void*)0))) |
| 2390 | return ( ((xmlSchemaValidCtxtPtr) actxt)->inode->nodeType); |
| 2391 | return (-1); |
| 2392 | } |
| 2393 | |
| 2394 | static int |
| 2395 | xmlSchemaIsGlobalItem(xmlSchemaTypePtr item) |
| 2396 | { |
| 2397 | switch (item->type) { |
| 2398 | case XML_SCHEMA_TYPE_COMPLEX: |
| 2399 | case XML_SCHEMA_TYPE_SIMPLE: |
| 2400 | if (item->flags & XML_SCHEMAS_TYPE_GLOBAL1 << 3) |
| 2401 | return(1); |
| 2402 | break; |
| 2403 | case XML_SCHEMA_TYPE_GROUP: |
| 2404 | return (1); |
| 2405 | case XML_SCHEMA_TYPE_ELEMENT: |
| 2406 | if ( ((xmlSchemaElementPtr) item)->flags & |
| 2407 | XML_SCHEMAS_ELEM_GLOBAL1 << 1) |
| 2408 | return(1); |
| 2409 | break; |
| 2410 | case XML_SCHEMA_TYPE_ATTRIBUTE: |
| 2411 | if ( ((xmlSchemaAttributePtr) item)->flags & |
| 2412 | XML_SCHEMAS_ATTR_GLOBAL1 << 0) |
| 2413 | return(1); |
| 2414 | break; |
| 2415 | /* Note that attribute groups are always global. */ |
| 2416 | default: |
| 2417 | return(1); |
| 2418 | } |
| 2419 | return (0); |
| 2420 | } |
| 2421 | |
| 2422 | static void |
| 2423 | xmlSchemaSimpleTypeErr(xmlSchemaAbstractCtxtPtr actxt, |
| 2424 | xmlParserErrors error, |
| 2425 | xmlNodePtr node, |
| 2426 | const xmlChar *value, |
| 2427 | xmlSchemaTypePtr type, |
| 2428 | int displayValue) |
| 2429 | { |
| 2430 | xmlChar *msg = NULL((void*)0); |
| 2431 | |
| 2432 | xmlSchemaFormatNodeForError(&msg, actxt, node); |
| 2433 | |
| 2434 | if (displayValue || (xmlSchemaEvalErrorNodeType(actxt, node) == |
| 2435 | XML_ATTRIBUTE_NODE)) |
| 2436 | msg = xmlStrcat(msg, BAD_CAST(xmlChar *) "'%s' is not a valid value of "); |
| 2437 | else |
| 2438 | msg = xmlStrcat(msg, BAD_CAST(xmlChar *) "The character content is not a valid " |
| 2439 | "value of "); |
| 2440 | |
| 2441 | if (! xmlSchemaIsGlobalItem(type)) |
| 2442 | msg = xmlStrcat(msg, BAD_CAST(xmlChar *) "the local "); |
| 2443 | else |
| 2444 | msg = xmlStrcat(msg, BAD_CAST(xmlChar *) "the "); |
| 2445 | |
| 2446 | if (WXS_IS_ATOMIC(type)(type->flags & 1 << 8)) |
| 2447 | msg = xmlStrcat(msg, BAD_CAST(xmlChar *) "atomic type"); |
| 2448 | else if (WXS_IS_LIST(type)(type->flags & 1 << 6)) |
| 2449 | msg = xmlStrcat(msg, BAD_CAST(xmlChar *) "list type"); |
| 2450 | else if (WXS_IS_UNION(type)(type->flags & 1 << 7)) |
| 2451 | msg = xmlStrcat(msg, BAD_CAST(xmlChar *) "union type"); |
| 2452 | |
| 2453 | if (xmlSchemaIsGlobalItem(type)) { |
| 2454 | xmlChar *str = NULL((void*)0); |
| 2455 | msg = xmlStrcat(msg, BAD_CAST(xmlChar *) " '"); |
| 2456 | if (type->builtInType != 0) { |
| 2457 | msg = xmlStrcat(msg, BAD_CAST(xmlChar *) "xs:"); |
| 2458 | msg = xmlStrcat(msg, type->name); |
| 2459 | } else |
| 2460 | msg = xmlStrcat(msg, |
| 2461 | xmlSchemaFormatQName(&str, |
| 2462 | type->targetNamespace, type->name)); |
| 2463 | msg = xmlStrcat(msg, BAD_CAST(xmlChar *) "'"); |
| 2464 | FREE_AND_NULL(str)if ((str) != ((void*)0)) { xmlFree((xmlChar *) (str)); str = ( (void*)0); }; |
| 2465 | } |
| 2466 | msg = xmlStrcat(msg, BAD_CAST(xmlChar *) ".\n"); |
| 2467 | if (displayValue || (xmlSchemaEvalErrorNodeType(actxt, node) == |
| 2468 | XML_ATTRIBUTE_NODE)) |
| 2469 | xmlSchemaErr(actxt, error, node, (const char *) msg, value, NULL((void*)0)); |
| 2470 | else |
| 2471 | xmlSchemaErr(actxt, error, node, (const char *) msg, NULL((void*)0), NULL((void*)0)); |
| 2472 | FREE_AND_NULL(msg)if ((msg) != ((void*)0)) { xmlFree((xmlChar *) (msg)); msg = ( (void*)0); } |
| 2473 | } |
| 2474 | |
| 2475 | static const xmlChar * |
| 2476 | xmlSchemaFormatErrorNodeQName(xmlChar ** str, |
| 2477 | xmlSchemaNodeInfoPtr ni, |
| 2478 | xmlNodePtr node) |
| 2479 | { |
| 2480 | if (node != NULL((void*)0)) { |
| 2481 | if (node->ns != NULL((void*)0)) |
| 2482 | return (xmlSchemaFormatQName(str, node->ns->href, node->name)); |
| 2483 | else |
| 2484 | return (xmlSchemaFormatQName(str, NULL((void*)0), node->name)); |
| 2485 | } else if (ni != NULL((void*)0)) |
| 2486 | return (xmlSchemaFormatQName(str, ni->nsName, ni->localName)); |
| 2487 | return (NULL((void*)0)); |
| 2488 | } |
| 2489 | |
| 2490 | static void |
| 2491 | xmlSchemaIllegalAttrErr(xmlSchemaAbstractCtxtPtr actxt, |
| 2492 | xmlParserErrors error, |
| 2493 | xmlSchemaAttrInfoPtr ni, |
| 2494 | xmlNodePtr node) |
| 2495 | { |
| 2496 | xmlChar *msg = NULL((void*)0), *str = NULL((void*)0); |
| 2497 | |
| 2498 | xmlSchemaFormatNodeForError(&msg, actxt, node); |
| 2499 | msg = xmlStrcat(msg, BAD_CAST(xmlChar *) "The attribute '%s' is not allowed.\n"); |
| 2500 | xmlSchemaErr(actxt, error, node, (const char *) msg, |
| 2501 | xmlSchemaFormatErrorNodeQName(&str, (xmlSchemaNodeInfoPtr) ni, node), |
| 2502 | NULL((void*)0)); |
| 2503 | FREE_AND_NULL(str)if ((str) != ((void*)0)) { xmlFree((xmlChar *) (str)); str = ( (void*)0); } |
| 2504 | FREE_AND_NULL(msg)if ((msg) != ((void*)0)) { xmlFree((xmlChar *) (msg)); msg = ( (void*)0); } |
| 2505 | } |
| 2506 | |
| 2507 | static void |
| 2508 | xmlSchemaComplexTypeErr(xmlSchemaAbstractCtxtPtr actxt, |
| 2509 | xmlParserErrors error, |
| 2510 | xmlNodePtr node, |
| 2511 | xmlSchemaTypePtr type ATTRIBUTE_UNUSED__attribute__((unused)), |
| 2512 | const char *message, |
| 2513 | int nbval, |
| 2514 | int nbneg, |
| 2515 | xmlChar **values) |
| 2516 | { |
| 2517 | xmlChar *str = NULL((void*)0), *msg = NULL((void*)0); |
| 2518 | xmlChar *localName, *nsName; |
| 2519 | const xmlChar *cur, *end; |
| 2520 | int i; |
| 2521 | |
| 2522 | xmlSchemaFormatNodeForError(&msg, actxt, node); |
| 2523 | msg = xmlStrcat(msg, (const xmlChar *) message); |
| 2524 | msg = xmlStrcat(msg, BAD_CAST(xmlChar *) "."); |
| 2525 | /* |
| 2526 | * Note that is does not make sense to report that we have a |
| 2527 | * wildcard here, since the wildcard might be unfolded into |
| 2528 | * multiple transitions. |
| 2529 | */ |
| 2530 | if (nbval + nbneg > 0) { |
| 2531 | if (nbval + nbneg > 1) { |
| 2532 | str = xmlStrdup(BAD_CAST(xmlChar *) " Expected is one of ( "); |
| 2533 | } else |
| 2534 | str = xmlStrdup(BAD_CAST(xmlChar *) " Expected is ( "); |
| 2535 | nsName = NULL((void*)0); |
| 2536 | |
| 2537 | for (i = 0; i < nbval + nbneg; i++) { |
| 2538 | cur = values[i]; |
| 2539 | if (cur == NULL((void*)0)) |
| 2540 | continue; |
| 2541 | if ((cur[0] == 'n') && (cur[1] == 'o') && (cur[2] == 't') && |
| 2542 | (cur[3] == ' ')) { |
| 2543 | cur += 4; |
| 2544 | str = xmlStrcat(str, BAD_CAST(xmlChar *) "##other"); |
| 2545 | } |
| 2546 | /* |
| 2547 | * Get the local name. |
| 2548 | */ |
| 2549 | localName = NULL((void*)0); |
| 2550 | |
| 2551 | end = cur; |
| 2552 | if (*end == '*') { |
| 2553 | localName = xmlStrdup(BAD_CAST(xmlChar *) "*"); |
| 2554 | end++; |
| 2555 | } else { |
| 2556 | while ((*end != 0) && (*end != '|')) |
| 2557 | end++; |
| 2558 | localName = xmlStrncat(localName, BAD_CAST(xmlChar *) cur, end - cur); |
| 2559 | } |
| 2560 | if (*end != 0) { |
| 2561 | end++; |
| 2562 | /* |
| 2563 | * Skip "*|*" if they come with negated expressions, since |
| 2564 | * they represent the same negated wildcard. |
| 2565 | */ |
| 2566 | if ((nbneg == 0) || (*end != '*') || (*localName != '*')) { |
| 2567 | /* |
| 2568 | * Get the namespace name. |
| 2569 | */ |
| 2570 | cur = end; |
| 2571 | if (*end == '*') { |
| 2572 | nsName = xmlStrdup(BAD_CAST(xmlChar *) "{*}"); |
| 2573 | } else { |
| 2574 | while (*end != 0) |
| 2575 | end++; |
| 2576 | |
| 2577 | if (i >= nbval) |
| 2578 | nsName = xmlStrdup(BAD_CAST(xmlChar *) "{##other:"); |
| 2579 | else |
| 2580 | nsName = xmlStrdup(BAD_CAST(xmlChar *) "{"); |
| 2581 | |
| 2582 | nsName = xmlStrncat(nsName, BAD_CAST(xmlChar *) cur, end - cur); |
| 2583 | nsName = xmlStrcat(nsName, BAD_CAST(xmlChar *) "}"); |
| 2584 | } |
| 2585 | str = xmlStrcat(str, BAD_CAST(xmlChar *) nsName); |
| 2586 | FREE_AND_NULL(nsName)if ((nsName) != ((void*)0)) { xmlFree((xmlChar *) (nsName)); nsName = ((void*)0); } |
| 2587 | } else { |
| 2588 | FREE_AND_NULL(localName)if ((localName) != ((void*)0)) { xmlFree((xmlChar *) (localName )); localName = ((void*)0); }; |
| 2589 | continue; |
| 2590 | } |
| 2591 | } |
| 2592 | str = xmlStrcat(str, BAD_CAST(xmlChar *) localName); |
| 2593 | FREE_AND_NULL(localName)if ((localName) != ((void*)0)) { xmlFree((xmlChar *) (localName )); localName = ((void*)0); }; |
| 2594 | |
| 2595 | if (i < nbval + nbneg -1) |
| 2596 | str = xmlStrcat(str, BAD_CAST(xmlChar *) ", "); |
| 2597 | } |
| 2598 | str = xmlStrcat(str, BAD_CAST(xmlChar *) " ).\n"); |
| 2599 | msg = xmlStrcat(msg, BAD_CAST(xmlChar *) str); |
| 2600 | FREE_AND_NULL(str)if ((str) != ((void*)0)) { xmlFree((xmlChar *) (str)); str = ( (void*)0); } |
| 2601 | } else |
| 2602 | msg = xmlStrcat(msg, BAD_CAST(xmlChar *) "\n"); |
| 2603 | xmlSchemaErr(actxt, error, node, (const char *) msg, NULL((void*)0), NULL((void*)0)); |
| 2604 | xmlFree(msg); |
| 2605 | } |
| 2606 | |
| 2607 | static void |
| 2608 | xmlSchemaFacetErr(xmlSchemaAbstractCtxtPtr actxt, |
| 2609 | xmlParserErrors error, |
| 2610 | xmlNodePtr node, |
| 2611 | const xmlChar *value, |
| 2612 | unsigned long length, |
| 2613 | xmlSchemaTypePtr type, |
| 2614 | xmlSchemaFacetPtr facet, |
| 2615 | const char *message, |
| 2616 | const xmlChar *str1, |
| 2617 | const xmlChar *str2) |
| 2618 | { |
| 2619 | xmlChar *str = NULL((void*)0), *msg = NULL((void*)0); |
| 2620 | xmlSchemaTypeType facetType; |
| 2621 | int nodeType = xmlSchemaEvalErrorNodeType(actxt, node); |
| 2622 | |
| 2623 | xmlSchemaFormatNodeForError(&msg, actxt, node); |
| 2624 | if (error == XML_SCHEMAV_CVC_ENUMERATION_VALID) { |
| 2625 | facetType = XML_SCHEMA_FACET_ENUMERATION; |
| 2626 | /* |
| 2627 | * If enumerations are validated, one must not expect the |
| 2628 | * facet to be given. |
| 2629 | */ |
| 2630 | } else |
| 2631 | facetType = facet->type; |
| 2632 | msg = xmlStrcat(msg, BAD_CAST(xmlChar *) "["); |
| 2633 | msg = xmlStrcat(msg, BAD_CAST(xmlChar *) "facet '"); |
| 2634 | msg = xmlStrcat(msg, xmlSchemaFacetTypeToString(facetType)); |
| 2635 | msg = xmlStrcat(msg, BAD_CAST(xmlChar *) "'] "); |
| 2636 | if (message == NULL((void*)0)) { |
| 2637 | /* |
| 2638 | * Use a default message. |
| 2639 | */ |
| 2640 | if ((facetType == XML_SCHEMA_FACET_LENGTH) || |
| 2641 | (facetType == XML_SCHEMA_FACET_MINLENGTH) || |
| 2642 | (facetType == XML_SCHEMA_FACET_MAXLENGTH)) { |
| 2643 | |
| 2644 | char len[25], actLen[25]; |
| 2645 | |
| 2646 | /* FIXME, TODO: What is the max expected string length of the |
| 2647 | * this value? |
| 2648 | */ |
| 2649 | if (nodeType == XML_ATTRIBUTE_NODE) |
| 2650 | msg = xmlStrcat(msg, BAD_CAST(xmlChar *) "The value '%s' has a length of '%s'; "); |
| 2651 | else |
| 2652 | msg = xmlStrcat(msg, BAD_CAST(xmlChar *) "The value has a length of '%s'; "); |
| 2653 | |
| 2654 | snprintf(len, 24, "%lu", xmlSchemaGetFacetValueAsULong(facet)); |
| 2655 | snprintf(actLen, 24, "%lu", length); |
| 2656 | |
| 2657 | if (facetType == XML_SCHEMA_FACET_LENGTH) |
| 2658 | msg = xmlStrcat(msg, |
| 2659 | BAD_CAST(xmlChar *) "this differs from the allowed length of '%s'.\n"); |
| 2660 | else if (facetType == XML_SCHEMA_FACET_MAXLENGTH) |
| 2661 | msg = xmlStrcat(msg, |
| 2662 | BAD_CAST(xmlChar *) "this exceeds the allowed maximum length of '%s'.\n"); |
| 2663 | else if (facetType == XML_SCHEMA_FACET_MINLENGTH) |
| 2664 | msg = xmlStrcat(msg, |
| 2665 | BAD_CAST(xmlChar *) "this underruns the allowed minimum length of '%s'.\n"); |
| 2666 | |
| 2667 | if (nodeType == XML_ATTRIBUTE_NODE) |
| 2668 | xmlSchemaErr3(actxt, error, node, (const char *) msg, |
| 2669 | value, (const xmlChar *) actLen, (const xmlChar *) len); |
| 2670 | else |
| 2671 | xmlSchemaErr(actxt, error, node, (const char *) msg, |
| 2672 | (const xmlChar *) actLen, (const xmlChar *) len); |
| 2673 | |
| 2674 | } else if (facetType == XML_SCHEMA_FACET_ENUMERATION) { |
| 2675 | msg = xmlStrcat(msg, BAD_CAST(xmlChar *) "The value '%s' is not an element " |
| 2676 | "of the set {%s}.\n"); |
| 2677 | xmlSchemaErr(actxt, error, node, (const char *) msg, value, |
| 2678 | xmlSchemaFormatFacetEnumSet(actxt, &str, type)); |
| 2679 | } else if (facetType == XML_SCHEMA_FACET_PATTERN) { |
| 2680 | msg = xmlStrcat(msg, BAD_CAST(xmlChar *) "The value '%s' is not accepted " |
| 2681 | "by the pattern '%s'.\n"); |
| 2682 | xmlSchemaErr(actxt, error, node, (const char *) msg, value, |
| 2683 | facet->value); |
| 2684 | } else if (facetType == XML_SCHEMA_FACET_MININCLUSIVE) { |
| 2685 | msg = xmlStrcat(msg, BAD_CAST(xmlChar *) "The value '%s' is less than the " |
| 2686 | "minimum value allowed ('%s').\n"); |
| 2687 | xmlSchemaErr(actxt, error, node, (const char *) msg, value, |
| 2688 | facet->value); |
| 2689 | } else if (facetType == XML_SCHEMA_FACET_MAXINCLUSIVE) { |
| 2690 | msg = xmlStrcat(msg, BAD_CAST(xmlChar *) "The value '%s' is greater than the " |
| 2691 | "maximum value allowed ('%s').\n"); |
| 2692 | xmlSchemaErr(actxt, error, node, (const char *) msg, value, |
| 2693 | facet->value); |
| 2694 | } else if (facetType == XML_SCHEMA_FACET_MINEXCLUSIVE) { |
| 2695 | msg = xmlStrcat(msg, BAD_CAST(xmlChar *) "The value '%s' must be greater than " |
| 2696 | "'%s'.\n"); |
| 2697 | xmlSchemaErr(actxt, error, node, (const char *) msg, value, |
| 2698 | facet->value); |
| 2699 | } else if (facetType == XML_SCHEMA_FACET_MAXEXCLUSIVE) { |
| 2700 | msg = xmlStrcat(msg, BAD_CAST(xmlChar *) "The value '%s' must be less than " |
| 2701 | "'%s'.\n"); |
| 2702 | xmlSchemaErr(actxt, error, node, (const char *) msg, value, |
| 2703 | facet->value); |
| 2704 | } else if (facetType == XML_SCHEMA_FACET_TOTALDIGITS) { |
| 2705 | msg = xmlStrcat(msg, BAD_CAST(xmlChar *) "The value '%s' has more " |
| 2706 | "digits than are allowed ('%s').\n"); |
| 2707 | xmlSchemaErr(actxt, error, node, (const char*) msg, value, |
| 2708 | facet->value); |
| 2709 | } else if (facetType == XML_SCHEMA_FACET_FRACTIONDIGITS) { |
| 2710 | msg = xmlStrcat(msg, BAD_CAST(xmlChar *) "The value '%s' has more fractional " |
| 2711 | "digits than are allowed ('%s').\n"); |
| 2712 | xmlSchemaErr(actxt, error, node, (const char*) msg, value, |
| 2713 | facet->value); |
| 2714 | } else if (nodeType == XML_ATTRIBUTE_NODE) { |
| 2715 | msg = xmlStrcat(msg, BAD_CAST(xmlChar *) "The value '%s' is not facet-valid.\n"); |
| 2716 | xmlSchemaErr(actxt, error, node, (const char *) msg, value, NULL((void*)0)); |
| 2717 | } else { |
| 2718 | msg = xmlStrcat(msg, BAD_CAST(xmlChar *) "The value is not facet-valid.\n"); |
| 2719 | xmlSchemaErr(actxt, error, node, (const char *) msg, NULL((void*)0), NULL((void*)0)); |
| 2720 | } |
| 2721 | } else { |
| 2722 | msg = xmlStrcat(msg, (const xmlChar *) message); |
| 2723 | msg = xmlStrcat(msg, BAD_CAST(xmlChar *) ".\n"); |
| 2724 | xmlSchemaErr(actxt, error, node, (const char *) msg, str1, str2); |
| 2725 | } |
| 2726 | FREE_AND_NULL(str)if ((str) != ((void*)0)) { xmlFree((xmlChar *) (str)); str = ( (void*)0); } |
| 2727 | xmlFree(msg); |
| 2728 | } |
| 2729 | |
| 2730 | #define VERROR(err, type, msg)xmlSchemaCustomErr((xmlSchemaAbstractCtxtPtr) vctxt, err, ((void *)0), type, msg, ((void*)0), ((void*)0)); \ |
| 2731 | xmlSchemaCustomErr(ACTXT_CAST(xmlSchemaAbstractCtxtPtr) vctxt, err, NULL((void*)0), type, msg, NULL((void*)0), NULL((void*)0)); |
| 2732 | |
| 2733 | #define VERROR_INT(func, msg)xmlSchemaInternalErr((xmlSchemaAbstractCtxtPtr) vctxt, func, msg ); xmlSchemaInternalErr(ACTXT_CAST(xmlSchemaAbstractCtxtPtr) vctxt, func, msg); |
| 2734 | |
| 2735 | #define PERROR_INT(func, msg)xmlSchemaInternalErr((xmlSchemaAbstractCtxtPtr) pctxt, func, msg ); xmlSchemaInternalErr(ACTXT_CAST(xmlSchemaAbstractCtxtPtr) pctxt, func, msg); |
| 2736 | #define PERROR_INT2(func, msg)xmlSchemaInternalErr((xmlSchemaAbstractCtxtPtr) ctxt, func, msg ); xmlSchemaInternalErr(ACTXT_CAST(xmlSchemaAbstractCtxtPtr) ctxt, func, msg); |
| 2737 | |
| 2738 | #define AERROR_INT(func, msg)xmlSchemaInternalErr(actxt, func, msg); xmlSchemaInternalErr(actxt, func, msg); |
| 2739 | |
| 2740 | |
| 2741 | /** |
| 2742 | * xmlSchemaPMissingAttrErr: |
| 2743 | * @ctxt: the schema validation context |
| 2744 | * @ownerDes: the designation of the owner |
| 2745 | * @ownerName: the name of the owner |
| 2746 | * @ownerItem: the owner as a schema object |
| 2747 | * @ownerElem: the owner as an element node |
| 2748 | * @node: the parent element node of the missing attribute node |
| 2749 | * @type: the corresponding type of the attribute node |
| 2750 | * |
| 2751 | * Reports an illegal attribute. |
| 2752 | */ |
| 2753 | static void |
| 2754 | xmlSchemaPMissingAttrErr(xmlSchemaParserCtxtPtr ctxt, |
| 2755 | xmlParserErrors error, |
| 2756 | xmlSchemaBasicItemPtr ownerItem, |
| 2757 | xmlNodePtr ownerElem, |
| 2758 | const char *name, |
| 2759 | const char *message) |
| 2760 | { |
| 2761 | xmlChar *des = NULL((void*)0); |
| 2762 | |
| 2763 | xmlSchemaFormatItemForReport(&des, NULL((void*)0), ownerItem, ownerElem); |
| 2764 | |
| 2765 | if (message != NULL((void*)0)) |
| 2766 | xmlSchemaPErr(ctxt, ownerElem, error, "%s: %s.\n", BAD_CAST(xmlChar *) des, BAD_CAST(xmlChar *) message); |
| 2767 | else |
| 2768 | xmlSchemaPErr(ctxt, ownerElem, error, |
| 2769 | "%s: The attribute '%s' is required but missing.\n", |
| 2770 | BAD_CAST(xmlChar *) des, BAD_CAST(xmlChar *) name); |
| 2771 | FREE_AND_NULL(des)if ((des) != ((void*)0)) { xmlFree((xmlChar *) (des)); des = ( (void*)0); }; |
| 2772 | } |
| 2773 | |
| 2774 | |
| 2775 | /** |
| 2776 | * xmlSchemaPResCompAttrErr: |
| 2777 | * @ctxt: the schema validation context |
| 2778 | * @error: the error code |
| 2779 | * @ownerDes: the designation of the owner |
| 2780 | * @ownerItem: the owner as a schema object |
| 2781 | * @ownerElem: the owner as an element node |
| 2782 | * @name: the name of the attribute holding the QName |
| 2783 | * @refName: the referenced local name |
| 2784 | * @refURI: the referenced namespace URI |
| 2785 | * @message: optional message |
| 2786 | * |
| 2787 | * Used to report QName attribute values that failed to resolve |
| 2788 | * to schema components. |
| 2789 | */ |
| 2790 | static void |
| 2791 | xmlSchemaPResCompAttrErr(xmlSchemaParserCtxtPtr ctxt, |
| 2792 | xmlParserErrors error, |
| 2793 | xmlSchemaBasicItemPtr ownerItem, |
| 2794 | xmlNodePtr ownerElem, |
| 2795 | const char *name, |
| 2796 | const xmlChar *refName, |
| 2797 | const xmlChar *refURI, |
| 2798 | xmlSchemaTypeType refType, |
| 2799 | const char *refTypeStr) |
| 2800 | { |
| 2801 | xmlChar *des = NULL((void*)0), *strA = NULL((void*)0); |
| 2802 | |
| 2803 | xmlSchemaFormatItemForReport(&des, NULL((void*)0), ownerItem, ownerElem); |
| 2804 | if (refTypeStr == NULL((void*)0)) |
| 2805 | refTypeStr = (const char *) xmlSchemaItemTypeToStr(refType); |
| 2806 | xmlSchemaPErrExt(ctxt, ownerElem, error, |
| 2807 | NULL((void*)0), NULL((void*)0), NULL((void*)0), |
| 2808 | "%s, attribute '%s': The QName value '%s' does not resolve to a(n) " |
| 2809 | "%s.\n", BAD_CAST(xmlChar *) des, BAD_CAST(xmlChar *) name, |
| 2810 | xmlSchemaFormatQName(&strA, refURI, refName), |
| 2811 | BAD_CAST(xmlChar *) refTypeStr, NULL((void*)0)); |
| 2812 | FREE_AND_NULL(des)if ((des) != ((void*)0)) { xmlFree((xmlChar *) (des)); des = ( (void*)0); } |
| 2813 | FREE_AND_NULL(strA)if ((strA) != ((void*)0)) { xmlFree((xmlChar *) (strA)); strA = ((void*)0); } |
| 2814 | } |
| 2815 | |
| 2816 | /** |
| 2817 | * xmlSchemaPCustomAttrErr: |
| 2818 | * @ctxt: the schema parser context |
| 2819 | * @error: the error code |
| 2820 | * @ownerDes: the designation of the owner |
| 2821 | * @ownerItem: the owner as a schema object |
| 2822 | * @attr: the illegal attribute node |
| 2823 | * |
| 2824 | * Reports an illegal attribute during the parse. |
| 2825 | */ |
| 2826 | static void |
| 2827 | xmlSchemaPCustomAttrErr(xmlSchemaParserCtxtPtr ctxt, |
| 2828 | xmlParserErrors error, |
| 2829 | xmlChar **ownerDes, |
| 2830 | xmlSchemaBasicItemPtr ownerItem, |
| 2831 | xmlAttrPtr attr, |
| 2832 | const char *msg) |
| 2833 | { |
| 2834 | xmlChar *des = NULL((void*)0); |
| 2835 | |
| 2836 | if (ownerDes == NULL((void*)0)) |
| 2837 | xmlSchemaFormatItemForReport(&des, NULL((void*)0), ownerItem, attr->parent); |
| 2838 | else if (*ownerDes == NULL((void*)0)) { |
| 2839 | xmlSchemaFormatItemForReport(ownerDes, NULL((void*)0), ownerItem, attr->parent); |
| 2840 | des = *ownerDes; |
| 2841 | } else |
| 2842 | des = *ownerDes; |
| 2843 | if (attr == NULL((void*)0)) { |
| 2844 | xmlSchemaPErrExt(ctxt, NULL((void*)0), error, NULL((void*)0), NULL((void*)0), NULL((void*)0), |
| 2845 | "%s, attribute '%s': %s.\n", |
| 2846 | BAD_CAST(xmlChar *) des, (const xmlChar *) "Unknown", |
| 2847 | (const xmlChar *) msg, NULL((void*)0), NULL((void*)0)); |
| 2848 | } else { |
| 2849 | xmlSchemaPErrExt(ctxt, (xmlNodePtr) attr, error, NULL((void*)0), NULL((void*)0), NULL((void*)0), |
| 2850 | "%s, attribute '%s': %s.\n", |
| 2851 | BAD_CAST(xmlChar *) des, attr->name, (const xmlChar *) msg, NULL((void*)0), NULL((void*)0)); |
| 2852 | } |
| 2853 | if (ownerDes == NULL((void*)0)) |
| 2854 | FREE_AND_NULL(des)if ((des) != ((void*)0)) { xmlFree((xmlChar *) (des)); des = ( (void*)0); }; |
| 2855 | } |
| 2856 | |
| 2857 | /** |
| 2858 | * xmlSchemaPIllegalAttrErr: |
| 2859 | * @ctxt: the schema parser context |
| 2860 | * @error: the error code |
| 2861 | * @ownerDes: the designation of the attribute's owner |
| 2862 | * @ownerItem: the attribute's owner item |
| 2863 | * @attr: the illegal attribute node |
| 2864 | * |
| 2865 | * Reports an illegal attribute during the parse. |
| 2866 | */ |
| 2867 | static void |
| 2868 | xmlSchemaPIllegalAttrErr(xmlSchemaParserCtxtPtr ctxt, |
| 2869 | xmlParserErrors error, |
| 2870 | xmlSchemaBasicItemPtr ownerComp ATTRIBUTE_UNUSED__attribute__((unused)), |
| 2871 | xmlAttrPtr attr) |
| 2872 | { |
| 2873 | xmlChar *strA = NULL((void*)0), *strB = NULL((void*)0); |
| 2874 | |
| 2875 | xmlSchemaFormatNodeForError(&strA, ACTXT_CAST(xmlSchemaAbstractCtxtPtr) ctxt, attr->parent); |
| 2876 | xmlSchemaErr4(ACTXT_CAST(xmlSchemaAbstractCtxtPtr) ctxt, error, (xmlNodePtr) attr, |
| 2877 | "%sThe attribute '%s' is not allowed.\n", BAD_CAST(xmlChar *) strA, |
| 2878 | xmlSchemaFormatQNameNs(&strB, attr->ns, attr->name), |
| 2879 | NULL((void*)0), NULL((void*)0)); |
| 2880 | FREE_AND_NULL(strA)if ((strA) != ((void*)0)) { xmlFree((xmlChar *) (strA)); strA = ((void*)0); }; |
| 2881 | FREE_AND_NULL(strB)if ((strB) != ((void*)0)) { xmlFree((xmlChar *) (strB)); strB = ((void*)0); }; |
| 2882 | } |
| 2883 | |
| 2884 | /** |
| 2885 | * xmlSchemaPCustomErr: |
| 2886 | * @ctxt: the schema parser context |
| 2887 | * @error: the error code |
| 2888 | * @itemDes: the designation of the schema item |
| 2889 | * @item: the schema item |
| 2890 | * @itemElem: the node of the schema item |
| 2891 | * @message: the error message |
| 2892 | * @str1: an optional param for the error message |
| 2893 | * @str2: an optional param for the error message |
| 2894 | * @str3: an optional param for the error message |
| 2895 | * |
| 2896 | * Reports an error during parsing. |
| 2897 | */ |
| 2898 | static void |
| 2899 | xmlSchemaPCustomErrExt(xmlSchemaParserCtxtPtr ctxt, |
| 2900 | xmlParserErrors error, |
| 2901 | xmlSchemaBasicItemPtr item, |
| 2902 | xmlNodePtr itemElem, |
| 2903 | const char *message, |
| 2904 | const xmlChar *str1, |
| 2905 | const xmlChar *str2, |
| 2906 | const xmlChar *str3) |
| 2907 | { |
| 2908 | xmlChar *des = NULL((void*)0), *msg = NULL((void*)0); |
| 2909 | |
| 2910 | xmlSchemaFormatItemForReport(&des, NULL((void*)0), item, itemElem); |
| 2911 | msg = xmlStrdup(BAD_CAST(xmlChar *) "%s: "); |
| 2912 | msg = xmlStrcat(msg, (const xmlChar *) message); |
| 2913 | msg = xmlStrcat(msg, BAD_CAST(xmlChar *) ".\n"); |
| 2914 | if ((itemElem == NULL((void*)0)) && (item != NULL((void*)0))) |
| 2915 | itemElem = WXS_ITEM_NODE(item)xmlSchemaGetComponentNode((xmlSchemaBasicItemPtr) (item)); |
| 2916 | xmlSchemaPErrExt(ctxt, itemElem, error, NULL((void*)0), NULL((void*)0), NULL((void*)0), |
| 2917 | (const char *) msg, BAD_CAST(xmlChar *) des, str1, str2, str3, NULL((void*)0)); |
| 2918 | FREE_AND_NULL(des)if ((des) != ((void*)0)) { xmlFree((xmlChar *) (des)); des = ( (void*)0); }; |
| 2919 | FREE_AND_NULL(msg)if ((msg) != ((void*)0)) { xmlFree((xmlChar *) (msg)); msg = ( (void*)0); }; |
| 2920 | } |
| 2921 | |
| 2922 | /** |
| 2923 | * xmlSchemaPCustomErr: |
| 2924 | * @ctxt: the schema parser context |
| 2925 | * @error: the error code |
| 2926 | * @itemDes: the designation of the schema item |
| 2927 | * @item: the schema item |
| 2928 | * @itemElem: the node of the schema item |
| 2929 | * @message: the error message |
| 2930 | * @str1: the optional param for the error message |
| 2931 | * |
| 2932 | * Reports an error during parsing. |
| 2933 | */ |
| 2934 | static void |
| 2935 | xmlSchemaPCustomErr(xmlSchemaParserCtxtPtr ctxt, |
| 2936 | xmlParserErrors error, |
| 2937 | xmlSchemaBasicItemPtr item, |
| 2938 | xmlNodePtr itemElem, |
| 2939 | const char *message, |
| 2940 | const xmlChar *str1) |
| 2941 | { |
| 2942 | xmlSchemaPCustomErrExt(ctxt, error, item, itemElem, message, |
| 2943 | str1, NULL((void*)0), NULL((void*)0)); |
| 2944 | } |
| 2945 | |
| 2946 | /** |
| 2947 | * xmlSchemaPAttrUseErr: |
| 2948 | * @ctxt: the schema parser context |
| 2949 | * @error: the error code |
| 2950 | * @itemDes: the designation of the schema type |
| 2951 | * @item: the schema type |
| 2952 | * @itemElem: the node of the schema type |
| 2953 | * @attr: the invalid schema attribute |
| 2954 | * @message: the error message |
| 2955 | * @str1: the optional param for the error message |
| 2956 | * |
| 2957 | * Reports an attribute use error during parsing. |
| 2958 | */ |
| 2959 | static void |
| 2960 | xmlSchemaPAttrUseErr4(xmlSchemaParserCtxtPtr ctxt, |
| 2961 | xmlParserErrors error, |
| 2962 | xmlNodePtr node, |
| 2963 | xmlSchemaBasicItemPtr ownerItem, |
| 2964 | const xmlSchemaAttributeUsePtr attruse, |
| 2965 | const char *message, |
| 2966 | const xmlChar *str1, const xmlChar *str2, |
| 2967 | const xmlChar *str3,const xmlChar *str4) |
| 2968 | { |
| 2969 | xmlChar *str = NULL((void*)0), *msg = NULL((void*)0); |
| 2970 | |
| 2971 | xmlSchemaFormatItemForReport(&msg, NULL((void*)0), ownerItem, NULL((void*)0)); |
| 2972 | msg = xmlStrcat(msg, BAD_CAST(xmlChar *) ", "); |
| 2973 | msg = xmlStrcat(msg, |
| 2974 | BAD_CAST(xmlChar *) xmlSchemaFormatItemForReport(&str, NULL((void*)0), |
| 2975 | WXS_BASIC_CAST(xmlSchemaBasicItemPtr) attruse, NULL((void*)0))); |
| 2976 | FREE_AND_NULL(str)if ((str) != ((void*)0)) { xmlFree((xmlChar *) (str)); str = ( (void*)0); }; |
| 2977 | msg = xmlStrcat(msg, BAD_CAST(xmlChar *) ": "); |
| 2978 | msg = xmlStrcat(msg, (const xmlChar *) message); |
| 2979 | msg = xmlStrcat(msg, BAD_CAST(xmlChar *) ".\n"); |
| 2980 | xmlSchemaErr4(ACTXT_CAST(xmlSchemaAbstractCtxtPtr) ctxt, error, node, |
| 2981 | (const char *) msg, str1, str2, str3, str4); |
| 2982 | xmlFree(msg); |
| 2983 | } |
| 2984 | |
| 2985 | /** |
| 2986 | * xmlSchemaPIllegalFacetAtomicErr: |
| 2987 | * @ctxt: the schema parser context |
| 2988 | * @error: the error code |
| 2989 | * @type: the schema type |
| 2990 | * @baseType: the base type of type |
| 2991 | * @facet: the illegal facet |
| 2992 | * |
| 2993 | * Reports an illegal facet for atomic simple types. |
| 2994 | */ |
| 2995 | static void |
| 2996 | xmlSchemaPIllegalFacetAtomicErr(xmlSchemaParserCtxtPtr ctxt, |
| 2997 | xmlParserErrors error, |
| 2998 | xmlSchemaTypePtr type, |
| 2999 | xmlSchemaTypePtr baseType, |
| 3000 | xmlSchemaFacetPtr facet) |
| 3001 | { |
| 3002 | xmlChar *des = NULL((void*)0), *strT = NULL((void*)0); |
| 3003 | |
| 3004 | xmlSchemaFormatItemForReport(&des, NULL((void*)0), WXS_BASIC_CAST(xmlSchemaBasicItemPtr) type, type->node); |
| 3005 | xmlSchemaPErrExt(ctxt, type->node, error, NULL((void*)0), NULL((void*)0), NULL((void*)0), |
| 3006 | "%s: The facet '%s' is not allowed on types derived from the " |
| 3007 | "type %s.\n", |
| 3008 | BAD_CAST(xmlChar *) des, xmlSchemaFacetTypeToString(facet->type), |
| 3009 | xmlSchemaFormatItemForReport(&strT, NULL((void*)0), WXS_BASIC_CAST(xmlSchemaBasicItemPtr) baseType, NULL((void*)0)), |
| 3010 | NULL((void*)0), NULL((void*)0)); |
| 3011 | FREE_AND_NULL(des)if ((des) != ((void*)0)) { xmlFree((xmlChar *) (des)); des = ( (void*)0); }; |
| 3012 | FREE_AND_NULL(strT)if ((strT) != ((void*)0)) { xmlFree((xmlChar *) (strT)); strT = ((void*)0); }; |
| 3013 | } |
| 3014 | |
| 3015 | /** |
| 3016 | * xmlSchemaPIllegalFacetListUnionErr: |
| 3017 | * @ctxt: the schema parser context |
| 3018 | * @error: the error code |
| 3019 | * @itemDes: the designation of the schema item involved |
| 3020 | * @item: the schema item involved |
| 3021 | * @facet: the illegal facet |
| 3022 | * |
| 3023 | * Reports an illegal facet for <list> and <union>. |
| 3024 | */ |
| 3025 | static void |
| 3026 | xmlSchemaPIllegalFacetListUnionErr(xmlSchemaParserCtxtPtr ctxt, |
| 3027 | xmlParserErrors error, |
| 3028 | xmlSchemaTypePtr type, |
| 3029 | xmlSchemaFacetPtr facet) |
| 3030 | { |
| 3031 | xmlChar *des = NULL((void*)0); |
| 3032 | |
| 3033 | xmlSchemaFormatItemForReport(&des, NULL((void*)0), WXS_BASIC_CAST(xmlSchemaBasicItemPtr) type, |
| 3034 | type->node); |
| 3035 | xmlSchemaPErr(ctxt, type->node, error, |
| 3036 | "%s: The facet '%s' is not allowed.\n", |
| 3037 | BAD_CAST(xmlChar *) des, xmlSchemaFacetTypeToString(facet->type)); |
| 3038 | FREE_AND_NULL(des)if ((des) != ((void*)0)) { xmlFree((xmlChar *) (des)); des = ( (void*)0); }; |
| 3039 | } |
| 3040 | |
| 3041 | /** |
| 3042 | * xmlSchemaPMutualExclAttrErr: |
| 3043 | * @ctxt: the schema validation context |
| 3044 | * @error: the error code |
| 3045 | * @elemDes: the designation of the parent element node |
| 3046 | * @attr: the bad attribute node |
| 3047 | * @type: the corresponding type of the attribute node |
| 3048 | * |
| 3049 | * Reports an illegal attribute. |
| 3050 | */ |
| 3051 | static void |
| 3052 | xmlSchemaPMutualExclAttrErr(xmlSchemaParserCtxtPtr ctxt, |
| 3053 | xmlParserErrors error, |
| 3054 | xmlSchemaBasicItemPtr ownerItem, |
| 3055 | xmlAttrPtr attr, |
| 3056 | const char *name1, |
| 3057 | const char *name2) |
| 3058 | { |
| 3059 | xmlChar *des = NULL((void*)0); |
| 3060 | |
| 3061 | xmlSchemaFormatItemForReport(&des, NULL((void*)0), WXS_BASIC_CAST(xmlSchemaBasicItemPtr) ownerItem, attr->parent); |
| 3062 | xmlSchemaPErrExt(ctxt, (xmlNodePtr) attr, error, NULL((void*)0), NULL((void*)0), NULL((void*)0), |
| 3063 | "%s: The attributes '%s' and '%s' are mutually exclusive.\n", |
| 3064 | BAD_CAST(xmlChar *) des, BAD_CAST(xmlChar *) name1, BAD_CAST(xmlChar *) name2, NULL((void*)0), NULL((void*)0)); |
| 3065 | FREE_AND_NULL(des)if ((des) != ((void*)0)) { xmlFree((xmlChar *) (des)); des = ( (void*)0); }; |
| 3066 | } |
| 3067 | |
| 3068 | /** |
| 3069 | * xmlSchemaPSimpleTypeErr: |
| 3070 | * @ctxt: the schema validation context |
| 3071 | * @error: the error code |
| 3072 | * @type: the type specifier |
| 3073 | * @ownerDes: the designation of the owner |
| 3074 | * @ownerItem: the schema object if existent |
| 3075 | * @node: the validated node |
| 3076 | * @value: the validated value |
| 3077 | * |
| 3078 | * Reports a simple type validation error. |
| 3079 | * TODO: Should this report the value of an element as well? |
| 3080 | */ |
| 3081 | static void |
| 3082 | xmlSchemaPSimpleTypeErr(xmlSchemaParserCtxtPtr ctxt, |
| 3083 | xmlParserErrors error, |
| 3084 | xmlSchemaBasicItemPtr ownerItem ATTRIBUTE_UNUSED__attribute__((unused)), |
| 3085 | xmlNodePtr node, |
| 3086 | xmlSchemaTypePtr type, |
| 3087 | const char *expected, |
| 3088 | const xmlChar *value, |
| 3089 | const char *message, |
| 3090 | const xmlChar *str1, |
| 3091 | const xmlChar *str2) |
| 3092 | { |
| 3093 | xmlChar *msg = NULL((void*)0); |
| 3094 | |
| 3095 | xmlSchemaFormatNodeForError(&msg, ACTXT_CAST(xmlSchemaAbstractCtxtPtr) ctxt, node); |
| 3096 | if (message == NULL((void*)0)) { |
| 3097 | /* |
| 3098 | * Use default messages. |
| 3099 | */ |
| 3100 | if (type != NULL((void*)0)) { |
| 3101 | if (node->type == XML_ATTRIBUTE_NODE) |
| 3102 | msg = xmlStrcat(msg, BAD_CAST(xmlChar *) "'%s' is not a valid value of "); |
| 3103 | else |
| 3104 | msg = xmlStrcat(msg, BAD_CAST(xmlChar *) "The character content is not a " |
| 3105 | "valid value of "); |
| 3106 | if (! xmlSchemaIsGlobalItem(type)) |
| 3107 | msg = xmlStrcat(msg, BAD_CAST(xmlChar *) "the local "); |
| 3108 | else |
| 3109 | msg = xmlStrcat(msg, BAD_CAST(xmlChar *) "the "); |
| 3110 | |
| 3111 | if (WXS_IS_ATOMIC(type)(type->flags & 1 << 8)) |
| 3112 | msg = xmlStrcat(msg, BAD_CAST(xmlChar *) "atomic type"); |
| 3113 | else if (WXS_IS_LIST(type)(type->flags & 1 << 6)) |
| 3114 | msg = xmlStrcat(msg, BAD_CAST(xmlChar *) "list type"); |
| 3115 | else if (WXS_IS_UNION(type)(type->flags & 1 << 7)) |
| 3116 | msg = xmlStrcat(msg, BAD_CAST(xmlChar *) "union type"); |
| 3117 | |
| 3118 | if (xmlSchemaIsGlobalItem(type)) { |
| 3119 | xmlChar *str = NULL((void*)0); |
| 3120 | msg = xmlStrcat(msg, BAD_CAST(xmlChar *) " '"); |
| 3121 | if (type->builtInType != 0) { |
| 3122 | msg = xmlStrcat(msg, BAD_CAST(xmlChar *) "xs:"); |
| 3123 | msg = xmlStrcat(msg, type->name); |
| 3124 | } else |
| 3125 | msg = xmlStrcat(msg, |
| 3126 | xmlSchemaFormatQName(&str, |
| 3127 | type->targetNamespace, type->name)); |
| 3128 | msg = xmlStrcat(msg, BAD_CAST(xmlChar *) "'."); |
| 3129 | FREE_AND_NULL(str)if ((str) != ((void*)0)) { xmlFree((xmlChar *) (str)); str = ( (void*)0); }; |
| 3130 | } |
| 3131 | } else { |
| 3132 | if (node->type == XML_ATTRIBUTE_NODE) |
| 3133 | msg = xmlStrcat(msg, BAD_CAST(xmlChar *) "The value '%s' is not valid."); |
| 3134 | else |
| 3135 | msg = xmlStrcat(msg, BAD_CAST(xmlChar *) "The character content is not " |
| 3136 | "valid."); |
| 3137 | } |
| 3138 | if (expected) { |
| 3139 | msg = xmlStrcat(msg, BAD_CAST(xmlChar *) " Expected is '"); |
| 3140 | msg = xmlStrcat(msg, BAD_CAST(xmlChar *) expected); |
| 3141 | msg = xmlStrcat(msg, BAD_CAST(xmlChar *) "'.\n"); |
| 3142 | } else |
| 3143 | msg = xmlStrcat(msg, BAD_CAST(xmlChar *) "\n"); |
| 3144 | if (node->type == XML_ATTRIBUTE_NODE) |
| 3145 | xmlSchemaPErr(ctxt, node, error, (const char *) msg, value, NULL((void*)0)); |
| 3146 | else |
| 3147 | xmlSchemaPErr(ctxt, node, error, (const char *) msg, NULL((void*)0), NULL((void*)0)); |
| 3148 | } else { |
| 3149 | msg = xmlStrcat(msg, BAD_CAST(xmlChar *) message); |
| 3150 | msg = xmlStrcat(msg, BAD_CAST(xmlChar *) ".\n"); |
| 3151 | xmlSchemaPErrExt(ctxt, node, error, NULL((void*)0), NULL((void*)0), NULL((void*)0), |
| 3152 | (const char*) msg, str1, str2, NULL((void*)0), NULL((void*)0), NULL((void*)0)); |
| 3153 | } |
| 3154 | /* Cleanup. */ |
| 3155 | FREE_AND_NULL(msg)if ((msg) != ((void*)0)) { xmlFree((xmlChar *) (msg)); msg = ( (void*)0); } |
| 3156 | } |
| 3157 | |
| 3158 | /** |
| 3159 | * xmlSchemaPContentErr: |
| 3160 | * @ctxt: the schema parser context |
| 3161 | * @error: the error code |
| 3162 | * @onwerDes: the designation of the holder of the content |
| 3163 | * @ownerItem: the owner item of the holder of the content |
| 3164 | * @ownerElem: the node of the holder of the content |
| 3165 | * @child: the invalid child node |
| 3166 | * @message: the optional error message |
| 3167 | * @content: the optional string describing the correct content |
| 3168 | * |
| 3169 | * Reports an error concerning the content of a schema element. |
| 3170 | */ |
| 3171 | static void |
| 3172 | xmlSchemaPContentErr(xmlSchemaParserCtxtPtr ctxt, |
| 3173 | xmlParserErrors error, |
| 3174 | xmlSchemaBasicItemPtr ownerItem, |
| 3175 | xmlNodePtr ownerElem, |
| 3176 | xmlNodePtr child, |
| 3177 | const char *message, |
| 3178 | const char *content) |
| 3179 | { |
| 3180 | xmlChar *des = NULL((void*)0); |
| 3181 | |
| 3182 | xmlSchemaFormatItemForReport(&des, NULL((void*)0), ownerItem, ownerElem); |
| 3183 | if (message != NULL((void*)0)) |
| 3184 | xmlSchemaPErr2(ctxt, ownerElem, child, error, |
| 3185 | "%s: %s.\n", |
| 3186 | BAD_CAST(xmlChar *) des, BAD_CAST(xmlChar *) message); |
| 3187 | else { |
| 3188 | if (content != NULL((void*)0)) { |
| 3189 | xmlSchemaPErr2(ctxt, ownerElem, child, error, |
| 3190 | "%s: The content is not valid. Expected is %s.\n", |
| 3191 | BAD_CAST(xmlChar *) des, BAD_CAST(xmlChar *) content); |
| 3192 | } else { |
| 3193 | xmlSchemaPErr2(ctxt, ownerElem, child, error, |
| 3194 | "%s: The content is not valid.\n", |
| 3195 | BAD_CAST(xmlChar *) des, NULL((void*)0)); |
| 3196 | } |
| 3197 | } |
| 3198 | FREE_AND_NULL(des)if ((des) != ((void*)0)) { xmlFree((xmlChar *) (des)); des = ( (void*)0); } |
| 3199 | } |
| 3200 | |
| 3201 | /************************************************************************ |
| 3202 | * * |
| 3203 | * Streamable error functions * |
| 3204 | * * |
| 3205 | ************************************************************************/ |
| 3206 | |
| 3207 | |
| 3208 | |
| 3209 | |
| 3210 | /************************************************************************ |
| 3211 | * * |
| 3212 | * Validation helper functions * |
| 3213 | * * |
| 3214 | ************************************************************************/ |
| 3215 | |
| 3216 | |
| 3217 | /************************************************************************ |
| 3218 | * * |
| 3219 | * Allocation functions * |
| 3220 | * * |
| 3221 | ************************************************************************/ |
| 3222 | |
| 3223 | /** |
| 3224 | * xmlSchemaNewSchemaForParserCtxt: |
| 3225 | * @ctxt: a schema validation context |
| 3226 | * |
| 3227 | * Allocate a new Schema structure. |
| 3228 | * |
| 3229 | * Returns the newly allocated structure or NULL in case or error |
| 3230 | */ |
| 3231 | static xmlSchemaPtr |
| 3232 | xmlSchemaNewSchema(xmlSchemaParserCtxtPtr ctxt) |
| 3233 | { |
| 3234 | xmlSchemaPtr ret; |
| 3235 | |
| 3236 | ret = (xmlSchemaPtr) xmlMalloc(sizeof(xmlSchema)); |
| 3237 | if (ret == NULL((void*)0)) { |
| 3238 | xmlSchemaPErrMemory(ctxt, "allocating schema", NULL((void*)0)); |
| 3239 | return (NULL((void*)0)); |
| 3240 | } |
| 3241 | memset(ret, 0, sizeof(xmlSchema)); |
| 3242 | ret->dict = ctxt->dict; |
| 3243 | xmlDictReference(ret->dict); |
| 3244 | |
| 3245 | return (ret); |
| 3246 | } |
| 3247 | |
| 3248 | /** |
| 3249 | * xmlSchemaNewFacet: |
| 3250 | * |
| 3251 | * Allocate a new Facet structure. |
| 3252 | * |
| 3253 | * Returns the newly allocated structure or NULL in case or error |
| 3254 | */ |
| 3255 | xmlSchemaFacetPtr |
| 3256 | xmlSchemaNewFacet(void) |
| 3257 | { |
| 3258 | xmlSchemaFacetPtr ret; |
| 3259 | |
| 3260 | ret = (xmlSchemaFacetPtr) xmlMalloc(sizeof(xmlSchemaFacet)); |
| 3261 | if (ret == NULL((void*)0)) { |
| 3262 | return (NULL((void*)0)); |
| 3263 | } |
| 3264 | memset(ret, 0, sizeof(xmlSchemaFacet)); |
| 3265 | |
| 3266 | return (ret); |
| 3267 | } |
| 3268 | |
| 3269 | /** |
| 3270 | * xmlSchemaNewAnnot: |
| 3271 | * @ctxt: a schema validation context |
| 3272 | * @node: a node |
| 3273 | * |
| 3274 | * Allocate a new annotation structure. |
| 3275 | * |
| 3276 | * Returns the newly allocated structure or NULL in case or error |
| 3277 | */ |
| 3278 | static xmlSchemaAnnotPtr |
| 3279 | xmlSchemaNewAnnot(xmlSchemaParserCtxtPtr ctxt, xmlNodePtr node) |
| 3280 | { |
| 3281 | xmlSchemaAnnotPtr ret; |
| 3282 | |
| 3283 | ret = (xmlSchemaAnnotPtr) xmlMalloc(sizeof(xmlSchemaAnnot)); |
| 3284 | if (ret == NULL((void*)0)) { |
| 3285 | xmlSchemaPErrMemory(ctxt, "allocating annotation", node); |
| 3286 | return (NULL((void*)0)); |
| 3287 | } |
| 3288 | memset(ret, 0, sizeof(xmlSchemaAnnot)); |
| 3289 | ret->content = node; |
| 3290 | return (ret); |
| 3291 | } |
| 3292 | |
| 3293 | static xmlSchemaItemListPtr |
| 3294 | xmlSchemaItemListCreate(void) |
| 3295 | { |
| 3296 | xmlSchemaItemListPtr ret; |
| 3297 | |
| 3298 | ret = xmlMalloc(sizeof(xmlSchemaItemList)); |
| 3299 | if (ret == NULL((void*)0)) { |
| 3300 | xmlSchemaPErrMemory(NULL((void*)0), |
| 3301 | "allocating an item list structure", NULL((void*)0)); |
| 3302 | return (NULL((void*)0)); |
| 3303 | } |
| 3304 | memset(ret, 0, sizeof(xmlSchemaItemList)); |
| 3305 | return (ret); |
| 3306 | } |
| 3307 | |
| 3308 | static void |
| 3309 | xmlSchemaItemListClear(xmlSchemaItemListPtr list) |
| 3310 | { |
| 3311 | if (list->items != NULL((void*)0)) { |
| 3312 | xmlFree(list->items); |
| 3313 | list->items = NULL((void*)0); |
| 3314 | } |
| 3315 | list->nbItems = 0; |
| 3316 | list->sizeItems = 0; |
| 3317 | } |
| 3318 | |
| 3319 | static int |
| 3320 | xmlSchemaItemListAdd(xmlSchemaItemListPtr list, void *item) |
| 3321 | { |
| 3322 | if (list->items == NULL((void*)0)) { |
| 3323 | list->items = (void **) xmlMalloc( |
| 3324 | 20 * sizeof(void *)); |
| 3325 | if (list->items == NULL((void*)0)) { |
| 3326 | xmlSchemaPErrMemory(NULL((void*)0), "allocating new item list", NULL((void*)0)); |
| 3327 | return(-1); |
| 3328 | } |
| 3329 | list->sizeItems = 20; |
| 3330 | } else if (list->sizeItems <= list->nbItems) { |
| 3331 | list->sizeItems *= 2; |
| 3332 | list->items = (void **) xmlRealloc(list->items, |
| 3333 | list->sizeItems * sizeof(void *)); |
| 3334 | if (list->items == NULL((void*)0)) { |
| 3335 | xmlSchemaPErrMemory(NULL((void*)0), "growing item list", NULL((void*)0)); |
| 3336 | list->sizeItems = 0; |
| 3337 | return(-1); |
| 3338 | } |
| 3339 | } |
| 3340 | list->items[list->nbItems++] = item; |
| 3341 | return(0); |
| 3342 | } |
| 3343 | |
| 3344 | static int |
| 3345 | xmlSchemaItemListAddSize(xmlSchemaItemListPtr list, |
| 3346 | int initialSize, |
| 3347 | void *item) |
| 3348 | { |
| 3349 | if (list->items == NULL((void*)0)) { |
| 3350 | if (initialSize <= 0) |
| 3351 | initialSize = 1; |
| 3352 | list->items = (void **) xmlMalloc( |
| 3353 | initialSize * sizeof(void *)); |
| 3354 | if (list->items == NULL((void*)0)) { |
| 3355 | xmlSchemaPErrMemory(NULL((void*)0), "allocating new item list", NULL((void*)0)); |
| 3356 | return(-1); |
| 3357 | } |
| 3358 | list->sizeItems = initialSize; |
| 3359 | } else if (list->sizeItems <= list->nbItems) { |
| 3360 | list->sizeItems *= 2; |
| 3361 | list->items = (void **) xmlRealloc(list->items, |
| 3362 | list->sizeItems * sizeof(void *)); |
| 3363 | if (list->items == NULL((void*)0)) { |
| 3364 | xmlSchemaPErrMemory(NULL((void*)0), "growing item list", NULL((void*)0)); |
| 3365 | list->sizeItems = 0; |
| 3366 | return(-1); |
| 3367 | } |
| 3368 | } |
| 3369 | list->items[list->nbItems++] = item; |
| 3370 | return(0); |
| 3371 | } |
| 3372 | |
| 3373 | static int |
| 3374 | xmlSchemaItemListInsert(xmlSchemaItemListPtr list, void *item, int idx) |
| 3375 | { |
| 3376 | if (list->items == NULL((void*)0)) { |
| 3377 | list->items = (void **) xmlMalloc( |
| 3378 | 20 * sizeof(void *)); |
| 3379 | if (list->items == NULL((void*)0)) { |
| 3380 | xmlSchemaPErrMemory(NULL((void*)0), "allocating new item list", NULL((void*)0)); |
| 3381 | return(-1); |
| 3382 | } |
| 3383 | list->sizeItems = 20; |
| 3384 | } else if (list->sizeItems <= list->nbItems) { |
| 3385 | list->sizeItems *= 2; |
| 3386 | list->items = (void **) xmlRealloc(list->items, |
| 3387 | list->sizeItems * sizeof(void *)); |
| 3388 | if (list->items == NULL((void*)0)) { |
| 3389 | xmlSchemaPErrMemory(NULL((void*)0), "growing item list", NULL((void*)0)); |
| 3390 | list->sizeItems = 0; |
| 3391 | return(-1); |
| 3392 | } |
| 3393 | } |
| 3394 | /* |
| 3395 | * Just append if the index is greater/equal than the item count. |
| 3396 | */ |
| 3397 | if (idx >= list->nbItems) { |
| 3398 | list->items[list->nbItems++] = item; |
| 3399 | } else { |
| 3400 | int i; |
| 3401 | for (i = list->nbItems; i > idx; i--) |
| 3402 | list->items[i] = list->items[i-1]; |
| 3403 | list->items[idx] = item; |
| 3404 | list->nbItems++; |
| 3405 | } |
| 3406 | return(0); |
| 3407 | } |
| 3408 | |
| 3409 | #if 0 /* enable if ever needed */ |
| 3410 | static int |
| 3411 | xmlSchemaItemListInsertSize(xmlSchemaItemListPtr list, |
| 3412 | int initialSize, |
| 3413 | void *item, |
| 3414 | int idx) |
| 3415 | { |
| 3416 | if (list->items == NULL((void*)0)) { |
| 3417 | if (initialSize <= 0) |
| 3418 | initialSize = 1; |
| 3419 | list->items = (void **) xmlMalloc( |
| 3420 | initialSize * sizeof(void *)); |
| 3421 | if (list->items == NULL((void*)0)) { |
| 3422 | xmlSchemaPErrMemory(NULL((void*)0), "allocating new item list", NULL((void*)0)); |
| 3423 | return(-1); |
| 3424 | } |
| 3425 | list->sizeItems = initialSize; |
| 3426 | } else if (list->sizeItems <= list->nbItems) { |
| 3427 | list->sizeItems *= 2; |
| 3428 | list->items = (void **) xmlRealloc(list->items, |
| 3429 | list->sizeItems * sizeof(void *)); |
| 3430 | if (list->items == NULL((void*)0)) { |
| 3431 | xmlSchemaPErrMemory(NULL((void*)0), "growing item list", NULL((void*)0)); |
| 3432 | list->sizeItems = 0; |
| 3433 | return(-1); |
| 3434 | } |
| 3435 | } |
| 3436 | /* |
| 3437 | * Just append if the index is greater/equal than the item count. |
| 3438 | */ |
| 3439 | if (idx >= list->nbItems) { |
| 3440 | list->items[list->nbItems++] = item; |
| 3441 | } else { |
| 3442 | int i; |
| 3443 | for (i = list->nbItems; i > idx; i--) |
| 3444 | list->items[i] = list->items[i-1]; |
| 3445 | list->items[idx] = item; |
| 3446 | list->nbItems++; |
| 3447 | } |
| 3448 | return(0); |
| 3449 | } |
| 3450 | #endif |
| 3451 | |
| 3452 | static int |
| 3453 | xmlSchemaItemListRemove(xmlSchemaItemListPtr list, int idx) |
| 3454 | { |
| 3455 | int i; |
| 3456 | if ((list->items == NULL((void*)0)) || (idx >= list->nbItems)) { |
| 3457 | xmlSchemaPSimpleErr("Internal error: xmlSchemaItemListRemove, " |
| 3458 | "index error.\n"); |
| 3459 | return(-1); |
| 3460 | } |
| 3461 | |
| 3462 | if (list->nbItems == 1) { |
| 3463 | /* TODO: Really free the list? */ |
| 3464 | xmlFree(list->items); |
| 3465 | list->items = NULL((void*)0); |
| 3466 | list->nbItems = 0; |
| 3467 | list->sizeItems = 0; |
| 3468 | } else if (list->nbItems -1 == idx) { |
| 3469 | list->nbItems--; |
| 3470 | } else { |
| 3471 | for (i = idx; i < list->nbItems -1; i++) |
| 3472 | list->items[i] = list->items[i+1]; |
| 3473 | list->nbItems--; |
| 3474 | } |
| 3475 | return(0); |
| 3476 | } |
| 3477 | |
| 3478 | /** |
| 3479 | * xmlSchemaItemListFree: |
| 3480 | * @annot: a schema type structure |
| 3481 | * |
| 3482 | * Deallocate a annotation structure |
| 3483 | */ |
| 3484 | static void |
| 3485 | xmlSchemaItemListFree(xmlSchemaItemListPtr list) |
| 3486 | { |
| 3487 | if (list == NULL((void*)0)) |
| 3488 | return; |
| 3489 | if (list->items != NULL((void*)0)) |
| 3490 | xmlFree(list->items); |
| 3491 | xmlFree(list); |
| 3492 | } |
| 3493 | |
| 3494 | static void |
| 3495 | xmlSchemaBucketFree(xmlSchemaBucketPtr bucket) |
| 3496 | { |
| 3497 | if (bucket == NULL((void*)0)) |
| 3498 | return; |
| 3499 | if (bucket->globals != NULL((void*)0)) { |
| 3500 | xmlSchemaComponentListFree(bucket->globals); |
| 3501 | xmlSchemaItemListFree(bucket->globals); |
| 3502 | } |
| 3503 | if (bucket->locals != NULL((void*)0)) { |
| 3504 | xmlSchemaComponentListFree(bucket->locals); |
| 3505 | xmlSchemaItemListFree(bucket->locals); |
| 3506 | } |
| 3507 | if (bucket->relations != NULL((void*)0)) { |
| 3508 | xmlSchemaSchemaRelationPtr prev, cur = bucket->relations; |
| 3509 | do { |
| 3510 | prev = cur; |
| 3511 | cur = cur->next; |
| 3512 | xmlFree(prev); |
| 3513 | } while (cur != NULL((void*)0)); |
| 3514 | } |
| 3515 | if ((! bucket->preserveDoc) && (bucket->doc != NULL((void*)0))) { |
| 3516 | xmlFreeDoc(bucket->doc); |
| 3517 | } |
| 3518 | if (bucket->type == XML_SCHEMA_SCHEMA_IMPORT1) { |
| 3519 | if (WXS_IMPBUCKET(bucket)((xmlSchemaImportPtr) (bucket))->schema != NULL((void*)0)) |
| 3520 | xmlSchemaFree(WXS_IMPBUCKET(bucket)((xmlSchemaImportPtr) (bucket))->schema); |
| 3521 | } |
| 3522 | xmlFree(bucket); |
| 3523 | } |
| 3524 | |
| 3525 | static xmlSchemaBucketPtr |
| 3526 | xmlSchemaBucketCreate(xmlSchemaParserCtxtPtr pctxt, |
| 3527 | int type, const xmlChar *targetNamespace) |
| 3528 | { |
| 3529 | xmlSchemaBucketPtr ret; |
| 3530 | int size; |
| 3531 | xmlSchemaPtr mainSchema; |
| 3532 | |
| 3533 | if (WXS_CONSTRUCTOR(pctxt)(pctxt)->constructor->mainSchema == NULL((void*)0)) { |
| 3534 | PERROR_INT("xmlSchemaBucketCreate",xmlSchemaInternalErr((xmlSchemaAbstractCtxtPtr) pctxt, "xmlSchemaBucketCreate" , "no main schema on constructor"); |
| 3535 | "no main schema on constructor")xmlSchemaInternalErr((xmlSchemaAbstractCtxtPtr) pctxt, "xmlSchemaBucketCreate" , "no main schema on constructor");; |
| 3536 | return(NULL((void*)0)); |
| 3537 | } |
| 3538 | mainSchema = WXS_CONSTRUCTOR(pctxt)(pctxt)->constructor->mainSchema; |
| 3539 | /* Create the schema bucket. */ |
| 3540 | if (WXS_IS_BUCKET_INCREDEF(type)(((type) == 2) || ((type) == 3))) |
| 3541 | size = sizeof(xmlSchemaInclude); |
| 3542 | else |
| 3543 | size = sizeof(xmlSchemaImport); |
| 3544 | ret = (xmlSchemaBucketPtr) xmlMalloc(size); |
| 3545 | if (ret == NULL((void*)0)) { |
| 3546 | xmlSchemaPErrMemory(NULL((void*)0), "allocating schema bucket", NULL((void*)0)); |
| 3547 | return(NULL((void*)0)); |
| 3548 | } |
| 3549 | memset(ret, 0, size); |
| 3550 | ret->targetNamespace = targetNamespace; |
| 3551 | ret->type = type; |
| 3552 | ret->globals = xmlSchemaItemListCreate(); |
| 3553 | if (ret->globals == NULL((void*)0)) { |
| 3554 | xmlFree(ret); |
| 3555 | return(NULL((void*)0)); |
| 3556 | } |
| 3557 | ret->locals = xmlSchemaItemListCreate(); |
| 3558 | if (ret->locals == NULL((void*)0)) { |
| 3559 | xmlFree(ret); |
| 3560 | return(NULL((void*)0)); |
| 3561 | } |
| 3562 | /* |
| 3563 | * The following will assure that only the first bucket is marked as |
| 3564 | * XML_SCHEMA_SCHEMA_MAIN and it points to the *main* schema. |
| 3565 | * For each following import buckets an xmlSchema will be created. |
| 3566 | * An xmlSchema will be created for every distinct targetNamespace. |
| 3567 | * We assign the targetNamespace to the schemata here. |
| 3568 | */ |
| 3569 | if (! WXS_HAS_BUCKETS(pctxt)( (((pctxt))->constructor->buckets != ((void*)0)) && (((pctxt))->constructor->buckets->nbItems > 0) )) { |
| 3570 | if (WXS_IS_BUCKET_INCREDEF(type)(((type) == 2) || ((type) == 3))) { |
| 3571 | PERROR_INT("xmlSchemaBucketCreate",xmlSchemaInternalErr((xmlSchemaAbstractCtxtPtr) pctxt, "xmlSchemaBucketCreate" , "first bucket but it's an include or redefine"); |
| 3572 | "first bucket but it's an include or redefine")xmlSchemaInternalErr((xmlSchemaAbstractCtxtPtr) pctxt, "xmlSchemaBucketCreate" , "first bucket but it's an include or redefine");; |
| 3573 | xmlSchemaBucketFree(ret); |
| 3574 | return(NULL((void*)0)); |
| 3575 | } |
| 3576 | /* Force the type to be XML_SCHEMA_SCHEMA_MAIN. */ |
| 3577 | ret->type = XML_SCHEMA_SCHEMA_MAIN0; |
| 3578 | /* Point to the *main* schema. */ |
| 3579 | WXS_CONSTRUCTOR(pctxt)(pctxt)->constructor->mainBucket = ret; |
| 3580 | WXS_IMPBUCKET(ret)((xmlSchemaImportPtr) (ret))->schema = mainSchema; |
| 3581 | /* |
| 3582 | * Ensure that the main schema gets a targetNamespace. |
| 3583 | */ |
| 3584 | mainSchema->targetNamespace = targetNamespace; |
| 3585 | } else { |
| 3586 | if (type == XML_SCHEMA_SCHEMA_MAIN0) { |
| 3587 | PERROR_INT("xmlSchemaBucketCreate",xmlSchemaInternalErr((xmlSchemaAbstractCtxtPtr) pctxt, "xmlSchemaBucketCreate" , "main bucket but it's not the first one"); |
| 3588 | "main bucket but it's not the first one")xmlSchemaInternalErr((xmlSchemaAbstractCtxtPtr) pctxt, "xmlSchemaBucketCreate" , "main bucket but it's not the first one");; |
| 3589 | xmlSchemaBucketFree(ret); |
| 3590 | return(NULL((void*)0)); |
| 3591 | } else if (type == XML_SCHEMA_SCHEMA_IMPORT1) { |
| 3592 | /* |
| 3593 | * Create a schema for imports and assign the |
| 3594 | * targetNamespace. |
| 3595 | */ |
| 3596 | WXS_IMPBUCKET(ret)((xmlSchemaImportPtr) (ret))->schema = xmlSchemaNewSchema(pctxt); |
| 3597 | if (WXS_IMPBUCKET(ret)((xmlSchemaImportPtr) (ret))->schema == NULL((void*)0)) { |
| 3598 | xmlSchemaBucketFree(ret); |
| 3599 | return(NULL((void*)0)); |
| 3600 | } |
| 3601 | WXS_IMPBUCKET(ret)((xmlSchemaImportPtr) (ret))->schema->targetNamespace = targetNamespace; |
| 3602 | } |
| 3603 | } |
| 3604 | if (WXS_IS_BUCKET_IMPMAIN(type)(((type) == 0) || ((type) == 1))) { |
| 3605 | int res; |
| 3606 | /* |
| 3607 | * Imports go into the "schemasImports" slot of the main *schema*. |
| 3608 | * Note that we create an import entry for the main schema as well; i.e., |
| 3609 | * even if there's only one schema, we'll get an import. |
| 3610 | */ |
| 3611 | if (mainSchema->schemasImports == NULL((void*)0)) { |
| 3612 | mainSchema->schemasImports = xmlHashCreateDict(5, |
| 3613 | WXS_CONSTRUCTOR(pctxt)(pctxt)->constructor->dict); |
| 3614 | if (mainSchema->schemasImports == NULL((void*)0)) { |
| 3615 | xmlSchemaBucketFree(ret); |
| 3616 | return(NULL((void*)0)); |
| 3617 | } |
| 3618 | } |
| 3619 | if (targetNamespace == NULL((void*)0)) |
| 3620 | res = xmlHashAddEntry(mainSchema->schemasImports, |
| 3621 | XML_SCHEMAS_NO_NAMESPACE(const xmlChar *) "##", ret); |
| 3622 | else |
| 3623 | res = xmlHashAddEntry(mainSchema->schemasImports, |
| 3624 | targetNamespace, ret); |
| 3625 | if (res != 0) { |
| 3626 | PERROR_INT("xmlSchemaBucketCreate",xmlSchemaInternalErr((xmlSchemaAbstractCtxtPtr) pctxt, "xmlSchemaBucketCreate" , "failed to add the schema bucket to the hash"); |
| 3627 | "failed to add the schema bucket to the hash")xmlSchemaInternalErr((xmlSchemaAbstractCtxtPtr) pctxt, "xmlSchemaBucketCreate" , "failed to add the schema bucket to the hash");; |
| 3628 | xmlSchemaBucketFree(ret); |
| 3629 | return(NULL((void*)0)); |
| 3630 | } |
| 3631 | } else { |
| 3632 | /* Set the @ownerImport of an include bucket. */ |
| 3633 | if (WXS_IS_BUCKET_IMPMAIN(WXS_CONSTRUCTOR(pctxt)->bucket->type)((((pctxt)->constructor->bucket->type) == 0) || (((pctxt )->constructor->bucket->type) == 1))) |
| 3634 | WXS_INCBUCKET(ret)((xmlSchemaIncludePtr) (ret))->ownerImport = |
| 3635 | WXS_IMPBUCKET(WXS_CONSTRUCTOR(pctxt)->bucket)((xmlSchemaImportPtr) ((pctxt)->constructor->bucket)); |
| 3636 | else |
| 3637 | WXS_INCBUCKET(ret)((xmlSchemaIncludePtr) (ret))->ownerImport = |
| 3638 | WXS_INCBUCKET(WXS_CONSTRUCTOR(pctxt)->bucket)((xmlSchemaIncludePtr) ((pctxt)->constructor->bucket))->ownerImport; |
| 3639 | |
| 3640 | /* Includes got into the "includes" slot of the *main* schema. */ |
| 3641 | if (mainSchema->includes == NULL((void*)0)) { |
| 3642 | mainSchema->includes = xmlSchemaItemListCreate(); |
| 3643 | if (mainSchema->includes == NULL((void*)0)) { |
| 3644 | xmlSchemaBucketFree(ret); |
| 3645 | return(NULL((void*)0)); |
| 3646 | } |
| 3647 | } |
| 3648 | xmlSchemaItemListAdd(mainSchema->includes, ret); |
| 3649 | } |
| 3650 | /* |
| 3651 | * Add to list of all buckets; this is used for lookup |
| 3652 | * during schema construction time only. |
| 3653 | */ |
| 3654 | if (xmlSchemaItemListAdd(WXS_CONSTRUCTOR(pctxt)(pctxt)->constructor->buckets, ret) == -1) |
| 3655 | return(NULL((void*)0)); |
| 3656 | return(ret); |
| 3657 | } |
| 3658 | |
| 3659 | static int |
| 3660 | xmlSchemaAddItemSize(xmlSchemaItemListPtr *list, int initialSize, void *item) |
| 3661 | { |
| 3662 | if (*list == NULL((void*)0)) { |
| 3663 | *list = xmlSchemaItemListCreate(); |
| 3664 | if (*list == NULL((void*)0)) |
| 3665 | return(-1); |
| 3666 | } |
| 3667 | xmlSchemaItemListAddSize(*list, initialSize, item); |
| 3668 | return(0); |
| 3669 | } |
| 3670 | |
| 3671 | /** |
| 3672 | * xmlSchemaFreeAnnot: |
| 3673 | * @annot: a schema type structure |
| 3674 | * |
| 3675 | * Deallocate a annotation structure |
| 3676 | */ |
| 3677 | static void |
| 3678 | xmlSchemaFreeAnnot(xmlSchemaAnnotPtr annot) |
| 3679 | { |
| 3680 | if (annot == NULL((void*)0)) |
| 3681 | return; |
| 3682 | if (annot->next == NULL((void*)0)) { |
| 3683 | xmlFree(annot); |
| 3684 | } else { |
| 3685 | xmlSchemaAnnotPtr prev; |
| 3686 | |
| 3687 | do { |
| 3688 | prev = annot; |
| 3689 | annot = annot->next; |
| 3690 | xmlFree(prev); |
| 3691 | } while (annot != NULL((void*)0)); |
| 3692 | } |
| 3693 | } |
| 3694 | |
| 3695 | /** |
| 3696 | * xmlSchemaFreeNotation: |
| 3697 | * @schema: a schema notation structure |
| 3698 | * |
| 3699 | * Deallocate a Schema Notation structure. |
| 3700 | */ |
| 3701 | static void |
| 3702 | xmlSchemaFreeNotation(xmlSchemaNotationPtr nota) |
| 3703 | { |
| 3704 | if (nota == NULL((void*)0)) |
| 3705 | return; |
| 3706 | xmlFree(nota); |
| 3707 | } |
| 3708 | |
| 3709 | /** |
| 3710 | * xmlSchemaFreeAttribute: |
| 3711 | * @attr: an attribute declaration |
| 3712 | * |
| 3713 | * Deallocates an attribute declaration structure. |
| 3714 | */ |
| 3715 | static void |
| 3716 | xmlSchemaFreeAttribute(xmlSchemaAttributePtr attr) |
| 3717 | { |
| 3718 | if (attr == NULL((void*)0)) |
| 3719 | return; |
| 3720 | if (attr->annot != NULL((void*)0)) |
| 3721 | xmlSchemaFreeAnnot(attr->annot); |
| 3722 | if (attr->defVal != NULL((void*)0)) |
| 3723 | xmlSchemaFreeValue(attr->defVal); |
| 3724 | xmlFree(attr); |
| 3725 | } |
| 3726 | |
| 3727 | /** |
| 3728 | * xmlSchemaFreeAttributeUse: |
| 3729 | * @use: an attribute use |
| 3730 | * |
| 3731 | * Deallocates an attribute use structure. |
| 3732 | */ |
| 3733 | static void |
| 3734 | xmlSchemaFreeAttributeUse(xmlSchemaAttributeUsePtr use) |
| 3735 | { |
| 3736 | if (use == NULL((void*)0)) |
| 3737 | return; |
| 3738 | if (use->annot != NULL((void*)0)) |
| 3739 | xmlSchemaFreeAnnot(use->annot); |
| 3740 | if (use->defVal != NULL((void*)0)) |
| 3741 | xmlSchemaFreeValue(use->defVal); |
| 3742 | xmlFree(use); |
| 3743 | } |
| 3744 | |
| 3745 | /** |
| 3746 | * xmlSchemaFreeAttributeUseProhib: |
| 3747 | * @prohib: an attribute use prohibition |
| 3748 | * |
| 3749 | * Deallocates an attribute use structure. |
| 3750 | */ |
| 3751 | static void |
| 3752 | xmlSchemaFreeAttributeUseProhib(xmlSchemaAttributeUseProhibPtr prohib) |
| 3753 | { |
| 3754 | if (prohib == NULL((void*)0)) |
| 3755 | return; |
| 3756 | xmlFree(prohib); |
| 3757 | } |
| 3758 | |
| 3759 | /** |
| 3760 | * xmlSchemaFreeWildcardNsSet: |
| 3761 | * set: a schema wildcard namespace |
| 3762 | * |
| 3763 | * Deallocates a list of wildcard constraint structures. |
| 3764 | */ |
| 3765 | static void |
| 3766 | xmlSchemaFreeWildcardNsSet(xmlSchemaWildcardNsPtr set) |
| 3767 | { |
| 3768 | xmlSchemaWildcardNsPtr next; |
| 3769 | |
| 3770 | while (set != NULL((void*)0)) { |
| 3771 | next = set->next; |
| 3772 | xmlFree(set); |
| 3773 | set = next; |
| 3774 | } |
| 3775 | } |
| 3776 | |
| 3777 | /** |
| 3778 | * xmlSchemaFreeWildcard: |
| 3779 | * @wildcard: a wildcard structure |
| 3780 | * |
| 3781 | * Deallocates a wildcard structure. |
| 3782 | */ |
| 3783 | void |
| 3784 | xmlSchemaFreeWildcard(xmlSchemaWildcardPtr wildcard) |
| 3785 | { |
| 3786 | if (wildcard == NULL((void*)0)) |
| 3787 | return; |
| 3788 | if (wildcard->annot != NULL((void*)0)) |
| 3789 | xmlSchemaFreeAnnot(wildcard->annot); |
| 3790 | if (wildcard->nsSet != NULL((void*)0)) |
| 3791 | xmlSchemaFreeWildcardNsSet(wildcard->nsSet); |
| 3792 | if (wildcard->negNsSet != NULL((void*)0)) |
| 3793 | xmlFree(wildcard->negNsSet); |
| 3794 | xmlFree(wildcard); |
| 3795 | } |
| 3796 | |
| 3797 | /** |
| 3798 | * xmlSchemaFreeAttributeGroup: |
| 3799 | * @schema: a sc |