* xmlSchemaParseComplexType: * @ctxt: a schema validation context * @schema: the schema being built * @node: a subtree containing XML Schema information * * parse a XML schema Complex Type definition * *WARNING* this interface is highly subject to change * * Returns the type definition or NULL in case of error */
| 12061 | * Returns the type definition or NULL in case of error |
| 12062 | */ |
| 12063 | static xmlSchemaTypePtr |
| 12064 | xmlSchemaParseComplexType(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema, |
| 12065 | xmlNodePtr node, int topLevel) |
| 12066 | { |
| 12067 | xmlSchemaTypePtr type, ctxtType; |
| 12068 | xmlNodePtr child = NULL; |
| 12069 | const xmlChar *name = NULL; |
| 12070 | xmlAttrPtr attr; |
| 12071 | const xmlChar *attrValue; |
| 12072 | #ifdef ENABLE_NAMED_LOCALS |
| 12073 | char buf[40]; |
| 12074 | #endif |
| 12075 | int final = 0, block = 0, hasRestrictionOrExtension = 0; |
| 12076 | |
| 12077 | |
| 12078 | if ((ctxt == NULL) || (schema == NULL) || (node == NULL)) |
| 12079 | return (NULL); |
| 12080 | |
| 12081 | ctxtType = ctxt->ctxtType; |
| 12082 | |
| 12083 | if (topLevel) { |
| 12084 | attr = xmlSchemaGetPropNode(node, "name"); |
| 12085 | if (attr == NULL) { |
| 12086 | xmlSchemaPMissingAttrErr(ctxt, |
| 12087 | XML_SCHEMAP_S4S_ATTR_MISSING, NULL, node, "name", NULL); |
| 12088 | return (NULL); |
| 12089 | } else if (xmlSchemaPValAttrNode(ctxt, NULL, attr, |
| 12090 | xmlSchemaGetBuiltInType(XML_SCHEMAS_NCNAME), &name) != 0) { |
| 12091 | return (NULL); |
| 12092 | } |
| 12093 | } |
| 12094 | |
| 12095 | if (topLevel == 0) { |
| 12096 | /* |
| 12097 | * Parse as local complex type definition. |
| 12098 | */ |
| 12099 | #ifdef ENABLE_NAMED_LOCALS |
| 12100 | snprintf(buf, 39, "#CT%d", ctxt->counter++ + 1); |
| 12101 | type = xmlSchemaAddType(ctxt, schema, |
| 12102 | XML_SCHEMA_TYPE_COMPLEX, |
| 12103 | xmlDictLookup(ctxt->dict, (const xmlChar *)buf, -1), |
| 12104 | ctxt->targetNamespace, node, 0); |
| 12105 | #else |
| 12106 | type = xmlSchemaAddType(ctxt, schema, |
| 12107 | XML_SCHEMA_TYPE_COMPLEX, |
| 12108 | NULL, ctxt->targetNamespace, node, 0); |
| 12109 | #endif |
| 12110 | if (type == NULL) |
| 12111 | return (NULL); |
| 12112 | name = type->name; |
| 12113 | type->node = node; |
| 12114 | type->type = XML_SCHEMA_TYPE_COMPLEX; |
| 12115 | /* |
| 12116 | * TODO: We need the target namespace. |
| 12117 | */ |
| 12118 | } else { |
| 12119 | /* |
| 12120 | * Parse as global complex type definition. |
no test coverage detected