* xmlSchemaParseSchemaTopLevel: * @ctxt: a schema validation context * @schema: the schemas * @nodes: the list of top level nodes * * Returns the internal XML Schema structure built from the resource or * NULL in case of error */
| 9719 | * NULL in case of error |
| 9720 | */ |
| 9721 | static int |
| 9722 | xmlSchemaParseSchemaTopLevel(xmlSchemaParserCtxtPtr ctxt, |
| 9723 | xmlSchemaPtr schema, xmlNodePtr nodes) |
| 9724 | { |
| 9725 | xmlNodePtr child; |
| 9726 | xmlSchemaAnnotPtr annot; |
| 9727 | int res = 0, oldErrs, tmpOldErrs; |
| 9728 | |
| 9729 | if ((ctxt == NULL) || (schema == NULL) || (nodes == NULL)) |
| 9730 | return(-1); |
| 9731 | |
| 9732 | oldErrs = ctxt->nberrors; |
| 9733 | child = nodes; |
| 9734 | while ((IS_SCHEMA(child, "include")) || |
| 9735 | (IS_SCHEMA(child, "import")) || |
| 9736 | (IS_SCHEMA(child, "redefine")) || |
| 9737 | (IS_SCHEMA(child, "annotation"))) { |
| 9738 | if (IS_SCHEMA(child, "annotation")) { |
| 9739 | annot = xmlSchemaParseAnnotation(ctxt, child, 1); |
| 9740 | if (schema->annot == NULL) |
| 9741 | schema->annot = annot; |
| 9742 | else |
| 9743 | xmlSchemaFreeAnnot(annot); |
| 9744 | } else if (IS_SCHEMA(child, "import")) { |
| 9745 | tmpOldErrs = ctxt->nberrors; |
| 9746 | res = xmlSchemaParseImport(ctxt, schema, child); |
| 9747 | HFAILURE; |
| 9748 | HSTOP(ctxt); |
| 9749 | if (tmpOldErrs != ctxt->nberrors) |
| 9750 | goto exit; |
| 9751 | } else if (IS_SCHEMA(child, "include")) { |
| 9752 | tmpOldErrs = ctxt->nberrors; |
| 9753 | res = xmlSchemaParseInclude(ctxt, schema, child); |
| 9754 | HFAILURE; |
| 9755 | HSTOP(ctxt); |
| 9756 | if (tmpOldErrs != ctxt->nberrors) |
| 9757 | goto exit; |
| 9758 | } else if (IS_SCHEMA(child, "redefine")) { |
| 9759 | tmpOldErrs = ctxt->nberrors; |
| 9760 | res = xmlSchemaParseRedefine(ctxt, schema, child); |
| 9761 | HFAILURE; |
| 9762 | HSTOP(ctxt); |
| 9763 | if (tmpOldErrs != ctxt->nberrors) |
| 9764 | goto exit; |
| 9765 | } |
| 9766 | child = child->next; |
| 9767 | } |
| 9768 | /* |
| 9769 | * URGENT TODO: Change the functions to return int results. |
| 9770 | * We need especially to catch internal errors. |
| 9771 | */ |
| 9772 | while (child != NULL) { |
| 9773 | if (IS_SCHEMA(child, "complexType")) { |
| 9774 | xmlSchemaParseComplexType(ctxt, schema, child, 1); |
| 9775 | child = child->next; |
| 9776 | } else if (IS_SCHEMA(child, "simpleType")) { |
| 9777 | xmlSchemaParseSimpleType(ctxt, schema, child, 1); |
| 9778 | child = child->next; |
no test coverage detected