| 3624 | } |
| 3625 | |
| 3626 | static xmlSchemaBucketPtr |
| 3627 | xmlSchemaBucketCreate(xmlSchemaParserCtxtPtr pctxt, |
| 3628 | int type, const xmlChar *targetNamespace) |
| 3629 | { |
| 3630 | xmlSchemaBucketPtr ret; |
| 3631 | int size; |
| 3632 | xmlSchemaPtr mainSchema; |
| 3633 | |
| 3634 | if (WXS_CONSTRUCTOR(pctxt)->mainSchema == NULL) { |
| 3635 | PERROR_INT("xmlSchemaBucketCreate", |
| 3636 | "no main schema on constructor"); |
| 3637 | return(NULL); |
| 3638 | } |
| 3639 | mainSchema = WXS_CONSTRUCTOR(pctxt)->mainSchema; |
| 3640 | /* Create the schema bucket. */ |
| 3641 | if (WXS_IS_BUCKET_INCREDEF(type)) |
| 3642 | size = sizeof(xmlSchemaInclude); |
| 3643 | else |
| 3644 | size = sizeof(xmlSchemaImport); |
| 3645 | ret = (xmlSchemaBucketPtr) xmlMalloc(size); |
| 3646 | if (ret == NULL) { |
| 3647 | xmlSchemaPErrMemory(NULL); |
| 3648 | return(NULL); |
| 3649 | } |
| 3650 | memset(ret, 0, size); |
| 3651 | ret->targetNamespace = targetNamespace; |
| 3652 | ret->type = type; |
| 3653 | ret->globals = xmlSchemaItemListCreate(); |
| 3654 | if (ret->globals == NULL) { |
| 3655 | xmlSchemaBucketFree(ret); |
| 3656 | return(NULL); |
| 3657 | } |
| 3658 | ret->locals = xmlSchemaItemListCreate(); |
| 3659 | if (ret->locals == NULL) { |
| 3660 | xmlSchemaBucketFree(ret); |
| 3661 | return(NULL); |
| 3662 | } |
| 3663 | /* |
| 3664 | * The following will assure that only the first bucket is marked as |
| 3665 | * XML_SCHEMA_SCHEMA_MAIN and it points to the *main* schema. |
| 3666 | * For each following import buckets an xmlSchema will be created. |
| 3667 | * An xmlSchema will be created for every distinct targetNamespace. |
| 3668 | * We assign the targetNamespace to the schemata here. |
| 3669 | */ |
| 3670 | if (! WXS_HAS_BUCKETS(pctxt)) { |
| 3671 | if (WXS_IS_BUCKET_INCREDEF(type)) { |
| 3672 | PERROR_INT("xmlSchemaBucketCreate", |
| 3673 | "first bucket but it's an include or redefine"); |
| 3674 | xmlSchemaBucketFree(ret); |
| 3675 | return(NULL); |
| 3676 | } |
| 3677 | /* Force the type to be XML_SCHEMA_SCHEMA_MAIN. */ |
| 3678 | ret->type = XML_SCHEMA_SCHEMA_MAIN; |
| 3679 | /* Point to the *main* schema. */ |
| 3680 | WXS_CONSTRUCTOR(pctxt)->mainBucket = ret; |
| 3681 | WXS_IMPBUCKET(ret)->schema = mainSchema; |
| 3682 | /* |
| 3683 | * Ensure that the main schema gets a targetNamespace. |
no test coverage detected