| 20635 | |
| 20636 | |
| 20637 | static int |
| 20638 | xmlSchemaAddComponents(xmlSchemaParserCtxtPtr pctxt, |
| 20639 | xmlSchemaBucketPtr bucket) |
| 20640 | { |
| 20641 | xmlSchemaBasicItemPtr item; |
| 20642 | int err; |
| 20643 | xmlHashTablePtr *table; |
| 20644 | const xmlChar *name; |
| 20645 | int i; |
| 20646 | |
| 20647 | #define WXS_GET_GLOBAL_HASH(c, slot) { \ |
| 20648 | if (WXS_IS_BUCKET_IMPMAIN((c)->type)) \ |
| 20649 | table = &(WXS_IMPBUCKET((c))->schema->slot); \ |
| 20650 | else \ |
| 20651 | table = &(WXS_INCBUCKET((c))->ownerImport->schema->slot); } |
| 20652 | |
| 20653 | /* |
| 20654 | * Add global components to the schema's hash tables. |
| 20655 | * This is the place where duplicate components will be |
| 20656 | * detected. |
| 20657 | * TODO: I think normally we should support imports of the |
| 20658 | * same namespace from multiple locations. We don't do currently, |
| 20659 | * but if we do then according to: |
| 20660 | * http://www.w3.org/Bugs/Public/show_bug.cgi?id=2224 |
| 20661 | * we would need, if imported directly, to import redefined |
| 20662 | * components as well to be able to catch clashing components. |
| 20663 | * (I hope I'll still know what this means after some months :-() |
| 20664 | */ |
| 20665 | if (bucket == NULL) |
| 20666 | return(-1); |
| 20667 | if (bucket->flags & XML_SCHEMA_BUCKET_COMPS_ADDED) |
| 20668 | return(0); |
| 20669 | bucket->flags |= XML_SCHEMA_BUCKET_COMPS_ADDED; |
| 20670 | |
| 20671 | for (i = 0; i < bucket->globals->nbItems; i++) { |
| 20672 | item = bucket->globals->items[i]; |
| 20673 | table = NULL; |
| 20674 | switch (item->type) { |
| 20675 | case XML_SCHEMA_TYPE_COMPLEX: |
| 20676 | case XML_SCHEMA_TYPE_SIMPLE: |
| 20677 | if (WXS_REDEFINED_TYPE(item)) |
| 20678 | continue; |
| 20679 | name = (WXS_TYPE_CAST item)->name; |
| 20680 | WXS_GET_GLOBAL_HASH(bucket, typeDecl) |
| 20681 | break; |
| 20682 | case XML_SCHEMA_TYPE_ELEMENT: |
| 20683 | name = (WXS_ELEM_CAST item)->name; |
| 20684 | WXS_GET_GLOBAL_HASH(bucket, elemDecl) |
| 20685 | break; |
| 20686 | case XML_SCHEMA_TYPE_ATTRIBUTE: |
| 20687 | name = (WXS_ATTR_CAST item)->name; |
| 20688 | WXS_GET_GLOBAL_HASH(bucket, attrDecl) |
| 20689 | break; |
| 20690 | case XML_SCHEMA_TYPE_GROUP: |
| 20691 | if (WXS_REDEFINED_MODEL_GROUP_DEF(item)) |
| 20692 | continue; |
| 20693 | name = (WXS_MODEL_GROUPDEF_CAST item)->name; |
| 20694 | WXS_GET_GLOBAL_HASH(bucket, groupDecl) |
no test coverage detected