зеркало из https://github.com/mozilla/gecko-dev.git
Bug 337179 - Schema with forward type definitions don't load. r=aaronr
This commit is contained in:
Родитель
148944fe8b
Коммит
fe6ba26cde
|
@ -127,7 +127,20 @@ nsSchemaComplexType::Resolve(nsIWebServiceErrorHandler* aErrorHandler)
|
|||
if (NS_FAILED(rv)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
mSimpleBaseType = do_QueryInterface(type);
|
||||
|
||||
// mSimpleBaseType could become a complex type under certain conditions
|
||||
// (simple content that restricts a complex type, which itself is a
|
||||
// simple content). So if we can't QI to a simple type, get the simple
|
||||
// base type if it is a complex type.
|
||||
if (!mSimpleBaseType) {
|
||||
nsCOMPtr<nsISchemaComplexType> complexType = do_QueryInterface(type);
|
||||
if (complexType) {
|
||||
complexType->GetSimpleBaseType(getter_AddRefs(mSimpleBaseType));
|
||||
}
|
||||
}
|
||||
|
||||
if (!mSimpleBaseType) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
|
|
@ -1847,28 +1847,34 @@ nsSchemaLoader::ProcessSimpleContentRestriction(nsIWebServiceErrorHandler* aErro
|
|||
// have a simple base type.
|
||||
nsCOMPtr<nsISchemaComplexType> complexBase = do_QueryInterface(aBaseType);
|
||||
if (!complexBase) {
|
||||
nsAutoString baseStr;
|
||||
rv = aBaseType->GetName(baseStr);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
// if base type is a place holder, this is ok
|
||||
PRUint16 schemaType;
|
||||
rv = aBaseType->GetSchemaType(&schemaType);
|
||||
|
||||
nsAutoString errorMsg;
|
||||
errorMsg.AppendLiteral("Failure processing schema, base type \"");
|
||||
errorMsg.Append(baseStr);
|
||||
errorMsg.AppendLiteral("\" of restriction must be a complex type ");
|
||||
errorMsg.AppendLiteral("which itself must be based on a simple type");
|
||||
if (NS_SUCCEEDED(rv) && schemaType == nsISchemaType::SCHEMA_TYPE_PLACEHOLDER) {
|
||||
simpleBase = do_QueryInterface(aBaseType);
|
||||
} else {
|
||||
nsAutoString baseStr;
|
||||
rv = aBaseType->GetName(baseStr);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
NS_SCHEMALOADER_FIRE_ERROR(NS_ERROR_SCHEMA_INVALID_TYPE_USAGE, errorMsg);
|
||||
nsAutoString errorMsg;
|
||||
errorMsg.AppendLiteral("Failure processing schema, base type \"");
|
||||
errorMsg.Append(baseStr);
|
||||
errorMsg.AppendLiteral("\" of restriction must be a complex type ");
|
||||
errorMsg.AppendLiteral("which itself must be based on a simple type");
|
||||
|
||||
return NS_ERROR_SCHEMA_INVALID_TYPE_USAGE;
|
||||
}
|
||||
NS_SCHEMALOADER_FIRE_ERROR(NS_ERROR_SCHEMA_INVALID_TYPE_USAGE, errorMsg);
|
||||
|
||||
nsCOMPtr<nsISchemaSimpleType> parentSimpleBase;
|
||||
complexBase->GetSimpleBaseType(getter_AddRefs(parentSimpleBase));
|
||||
return NS_ERROR_SCHEMA_INVALID_TYPE_USAGE;
|
||||
}
|
||||
} else {
|
||||
nsCOMPtr<nsISchemaSimpleType> parentSimpleBase;
|
||||
complexBase->GetSimpleBaseType(getter_AddRefs(parentSimpleBase));
|
||||
|
||||
if (parentSimpleBase) {
|
||||
rv = restrictionInst->SetBaseType(parentSimpleBase);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
if (parentSimpleBase) {
|
||||
rv = restrictionInst->SetBaseType(parentSimpleBase);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1880,14 +1886,10 @@ nsSchemaLoader::ProcessSimpleContentRestriction(nsIWebServiceErrorHandler* aErro
|
|||
|
||||
rv = ProcessSimpleType(aErrorHandler, aSchema, childElement,
|
||||
getter_AddRefs(simpleType));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = restrictionInst->SetBaseType(simpleType);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
else if ((tagName == nsSchemaAtoms::sMinExclusive_atom) ||
|
||||
(tagName == nsSchemaAtoms::sMinInclusive_atom) ||
|
||||
|
@ -1905,14 +1907,10 @@ nsSchemaLoader::ProcessSimpleContentRestriction(nsIWebServiceErrorHandler* aErro
|
|||
|
||||
rv = ProcessFacet(aErrorHandler, aSchema, childElement,
|
||||
tagName, getter_AddRefs(facet));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = restrictionInst->AddFacet(facet);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
else if ((tagName == nsSchemaAtoms::sAttribute_atom) ||
|
||||
(tagName == nsSchemaAtoms::sAttributeGroup_atom) ||
|
||||
|
@ -1922,14 +1920,10 @@ nsSchemaLoader::ProcessSimpleContentRestriction(nsIWebServiceErrorHandler* aErro
|
|||
rv = ProcessAttributeComponent(aErrorHandler, aSchema,
|
||||
childElement, tagName,
|
||||
getter_AddRefs(attribute));
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = aComplexType->AddAttribute(attribute);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче