Bug 286630 - nsSchemaLoader doesn't bail on invalid elements as direct children of xs:schema. r/sr=peterv

This commit is contained in:
doronr%us.ibm.com 2005-03-22 19:03:42 +00:00
parent 77dcedc423
commit 42778d84a6
2 changed files with 26 additions and 9 deletions

View File

@ -98,6 +98,10 @@ SCHEMA_ATOM(sAnyAttribute_atom, "anyAttribute")
SCHEMA_ATOM(sRestriction_atom, "restriction")
SCHEMA_ATOM(sExtension_atom, "extension")
SCHEMA_ATOM(sAnnotation_atom, "annotation")
SCHEMA_ATOM(sNotation_atom, "notation")
SCHEMA_ATOM(sInclude_atom, "include")
SCHEMA_ATOM(sImport_atom, "import")
SCHEMA_ATOM(sRedefine_atom, "redefine")
SCHEMA_ATOM(sList_atom, "list")
SCHEMA_ATOM(sUnion_atom, "union")

View File

@ -797,6 +797,14 @@ nsSchemaLoader::ProcessSchemaElement(nsIDOMElement* aElement,
nsCOMPtr<nsIDOMElement> childElement;
nsCOMPtr<nsIAtom> tagName;
// For now, ignore the following
// annotations
// include
// import
// redefine
// notation
// identity-constraint elements
while (NS_SUCCEEDED(iterator.GetNextChild(getter_AddRefs(childElement),
getter_AddRefs(tagName))) &&
childElement) {
@ -847,15 +855,12 @@ nsSchemaLoader::ProcessSchemaElement(nsIDOMElement* aElement,
if (NS_SUCCEEDED(rv)) {
rv = schemaInst->AddModelGroup(modelGroup);
}
}
// For now, ignore the following
// annotations
// include
// import
// redefine
// notation
// identity-constraint elements
if (NS_FAILED(rv)) {
} else if (tagName != nsSchemaAtoms::sAnnotation_atom &&
tagName != nsSchemaAtoms::sInclude_atom &&
tagName != nsSchemaAtoms::sImport_atom &&
tagName != nsSchemaAtoms::sRedefine_atom &&
tagName != nsSchemaAtoms::sNotation_atom) {
// if it is none of these, unexpected element.
nsAutoString elementName;
nsresult rc = aElement->GetTagName(elementName);
NS_ENSURE_SUCCESS(rc, rc);
@ -867,6 +872,14 @@ nsSchemaLoader::ProcessSchemaElement(nsIDOMElement* aElement,
NS_SCHEMALOADER_FIRE_ERROR(rv, errorMsg);
return NS_ERROR_UNEXPECTED;
}
if (NS_FAILED(rv)) {
nsAutoString errorMsg;
errorMsg.AppendLiteral("Failure processing schema");
NS_SCHEMALOADER_FIRE_ERROR(rv, errorMsg);
return rv;
}
}