* xmlSchemaParseModelGroup: * @ctxt: a schema validation context * @schema: the schema being built * @node: a subtree containing XML Schema information * @type: the "compositor" type * @particleNeeded: if a a model group with a particle * * parse a XML schema Sequence definition. * Applies parts of: * Schema Representation Constraint: * Redefinition Constraints and Semantics (sr
| 11171 | * 1 in case of success. |
| 11172 | */ |
| 11173 | static xmlSchemaTreeItemPtr |
| 11174 | xmlSchemaParseModelGroup(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema, |
| 11175 | xmlNodePtr node, xmlSchemaTypeType type, |
| 11176 | int withParticle) |
| 11177 | { |
| 11178 | xmlSchemaModelGroupPtr item; |
| 11179 | xmlSchemaParticlePtr particle = NULL; |
| 11180 | xmlNodePtr child = NULL; |
| 11181 | xmlAttrPtr attr; |
| 11182 | int min = 1, max = 1, isElemRef, hasRefs = 0; |
| 11183 | |
| 11184 | if ((ctxt == NULL) || (schema == NULL) || (node == NULL)) |
| 11185 | return (NULL); |
| 11186 | /* |
| 11187 | * Create a model group with the given compositor. |
| 11188 | */ |
| 11189 | item = xmlSchemaAddModelGroup(ctxt, schema, type, node); |
| 11190 | if (item == NULL) |
| 11191 | return (NULL); |
| 11192 | |
| 11193 | if (withParticle) { |
| 11194 | if (type == XML_SCHEMA_TYPE_ALL) { |
| 11195 | min = xmlGetMinOccurs(ctxt, node, 0, 1, 1, "(0 | 1)"); |
| 11196 | max = xmlGetMaxOccurs(ctxt, node, 1, 1, 1, "1"); |
| 11197 | } else { |
| 11198 | /* choice + sequence */ |
| 11199 | min = xmlGetMinOccurs(ctxt, node, 0, -1, 1, "xs:nonNegativeInteger"); |
| 11200 | max = xmlGetMaxOccurs(ctxt, node, 0, UNBOUNDED, 1, |
| 11201 | "(xs:nonNegativeInteger | unbounded)"); |
| 11202 | } |
| 11203 | xmlSchemaPCheckParticleCorrect_2(ctxt, NULL, node, min, max); |
| 11204 | /* |
| 11205 | * Create a particle |
| 11206 | */ |
| 11207 | particle = xmlSchemaAddParticle(ctxt, node, min, max); |
| 11208 | if (particle == NULL) |
| 11209 | return (NULL); |
| 11210 | particle->children = (xmlSchemaTreeItemPtr) item; |
| 11211 | /* |
| 11212 | * Check for illegal attributes. |
| 11213 | */ |
| 11214 | attr = node->properties; |
| 11215 | while (attr != NULL) { |
| 11216 | if (attr->ns == NULL) { |
| 11217 | if ((!xmlStrEqual(attr->name, BAD_CAST "id")) && |
| 11218 | (!xmlStrEqual(attr->name, BAD_CAST "maxOccurs")) && |
| 11219 | (!xmlStrEqual(attr->name, BAD_CAST "minOccurs"))) { |
| 11220 | xmlSchemaPIllegalAttrErr(ctxt, |
| 11221 | XML_SCHEMAP_S4S_ATTR_NOT_ALLOWED, NULL, attr); |
| 11222 | } |
| 11223 | } else if (xmlStrEqual(attr->ns->href, xmlSchemaNs)) { |
| 11224 | xmlSchemaPIllegalAttrErr(ctxt, |
| 11225 | XML_SCHEMAP_S4S_ATTR_NOT_ALLOWED, NULL, attr); |
| 11226 | } |
| 11227 | attr = attr->next; |
| 11228 | } |
| 11229 | } else { |
| 11230 | /* |
no test coverage detected