* xmlSchemaParseModelGroupDefRef: * @ctxt: the parser context * @schema: the schema being built * @node: the node * * Parses a reference to a model group definition. * * We will return a particle component with a qname-component or * NULL in case of an error. */
| 9319 | * NULL in case of an error. |
| 9320 | */ |
| 9321 | static xmlSchemaTreeItemPtr |
| 9322 | xmlSchemaParseModelGroupDefRef(xmlSchemaParserCtxtPtr ctxt, |
| 9323 | xmlSchemaPtr schema, |
| 9324 | xmlNodePtr node) |
| 9325 | { |
| 9326 | xmlSchemaParticlePtr item; |
| 9327 | xmlNodePtr child = NULL; |
| 9328 | xmlAttrPtr attr; |
| 9329 | const xmlChar *ref = NULL, *refNs = NULL; |
| 9330 | int min, max; |
| 9331 | |
| 9332 | if ((ctxt == NULL) || (schema == NULL) || (node == NULL)) |
| 9333 | return (NULL); |
| 9334 | |
| 9335 | attr = xmlSchemaGetPropNode(node, "ref"); |
| 9336 | if (attr == NULL) { |
| 9337 | xmlSchemaPMissingAttrErr(ctxt, |
| 9338 | XML_SCHEMAP_S4S_ATTR_MISSING, |
| 9339 | NULL, node, "ref", NULL); |
| 9340 | return (NULL); |
| 9341 | } else if (xmlSchemaPValAttrNodeQName(ctxt, schema, NULL, |
| 9342 | attr, &refNs, &ref) != 0) { |
| 9343 | return (NULL); |
| 9344 | } |
| 9345 | xmlSchemaCheckReference(ctxt, schema, node, attr, refNs); |
| 9346 | min = xmlGetMinOccurs(ctxt, node, 0, -1, 1, "xs:nonNegativeInteger"); |
| 9347 | max = xmlGetMaxOccurs(ctxt, node, 0, UNBOUNDED, 1, |
| 9348 | "(xs:nonNegativeInteger | unbounded)"); |
| 9349 | /* |
| 9350 | * Check for illegal attributes. |
| 9351 | */ |
| 9352 | attr = node->properties; |
| 9353 | while (attr != NULL) { |
| 9354 | if (attr->ns == NULL) { |
| 9355 | if ((!xmlStrEqual(attr->name, BAD_CAST "ref")) && |
| 9356 | (!xmlStrEqual(attr->name, BAD_CAST "id")) && |
| 9357 | (!xmlStrEqual(attr->name, BAD_CAST "minOccurs")) && |
| 9358 | (!xmlStrEqual(attr->name, BAD_CAST "maxOccurs"))) { |
| 9359 | xmlSchemaPIllegalAttrErr(ctxt, |
| 9360 | XML_SCHEMAP_S4S_ATTR_NOT_ALLOWED, NULL, attr); |
| 9361 | } |
| 9362 | } else if (xmlStrEqual(attr->ns->href, xmlSchemaNs)) { |
| 9363 | xmlSchemaPIllegalAttrErr(ctxt, |
| 9364 | XML_SCHEMAP_S4S_ATTR_NOT_ALLOWED, NULL, attr); |
| 9365 | } |
| 9366 | attr = attr->next; |
| 9367 | } |
| 9368 | xmlSchemaPValAttrID(ctxt, node, BAD_CAST "id"); |
| 9369 | item = xmlSchemaAddParticle(ctxt, node, min, max); |
| 9370 | if (item == NULL) |
| 9371 | return (NULL); |
| 9372 | /* |
| 9373 | * Create a qname-reference and set as the term; it will be substituted |
| 9374 | * for the model group after the reference has been resolved. |
| 9375 | */ |
| 9376 | item->children = (xmlSchemaTreeItemPtr) |
| 9377 | xmlSchemaNewQNameRef(ctxt, XML_SCHEMA_TYPE_GROUP, ref, refNs); |
| 9378 | xmlSchemaPCheckParticleCorrect_2(ctxt, item, node, min, max); |
no test coverage detected