From ef498a5f2b6ab2a444b9805f55489131fc43d344 Mon Sep 17 00:00:00 2001 From: "doronr%us.ibm.com" Date: Wed, 15 Mar 2006 17:13:09 +0000 Subject: [PATCH] Bug 329970 - nsSchemaLoader does not copy over attributes for DERIVATION_RESTRICTION_COMPLEX r=peterv git-svn-id: svn://10.0.0.236/trunk@192425 18797224-902f-48f8-a5cc-f745e15eee43 --- .../webservices/schema/src/nsSchemaLoader.cpp | 82 ++++++++++--------- 1 file changed, 43 insertions(+), 39 deletions(-) diff --git a/mozilla/extensions/webservices/schema/src/nsSchemaLoader.cpp b/mozilla/extensions/webservices/schema/src/nsSchemaLoader.cpp index cf5bf0e048d..cba3e3a2d93 100644 --- a/mozilla/extensions/webservices/schema/src/nsSchemaLoader.cpp +++ b/mozilla/extensions/webservices/schema/src/nsSchemaLoader.cpp @@ -2057,7 +2057,9 @@ nsSchemaLoader::ProcessComplexContent(nsIWebServiceErrorHandler* aErrorHandler, return rv; } - + + nsCOMPtr complexBaseType(do_QueryInterface(baseType)); + if (tagName == nsSchemaAtoms::sRestriction_atom) { *aDerivation = nsISchemaComplexType::DERIVATION_RESTRICTION_COMPLEX; rv = ProcessComplexTypeBody(aErrorHandler, aSchema, childElement, @@ -2068,7 +2070,6 @@ nsSchemaLoader::ProcessComplexContent(nsIWebServiceErrorHandler* aErrorHandler, nsCOMPtr sequence; nsSchemaModelGroup* sequenceInst = nsnull; - nsCOMPtr complexBaseType(do_QueryInterface(baseType)); if (complexBaseType) { // XXX Should really be cloning nsCOMPtr baseGroup; @@ -2144,43 +2145,6 @@ nsSchemaLoader::ProcessComplexContent(nsIWebServiceErrorHandler* aErrorHandler, } aComplexType->SetModelGroup(sequence); - } - - - // Copy over the attributes from the base type - // XXX Should really be cloning - PRUint32 attrIndex, attrCount; - complexBaseType->GetAttributeCount(&attrCount); - - for (attrIndex = 0; attrIndex < attrCount; attrIndex++) { - nsCOMPtr attribute; - - rv = complexBaseType->GetAttributeByIndex(attrIndex, - getter_AddRefs(attribute)); - if (NS_FAILED(rv)) { - nsAutoString errorMsg; - errorMsg.AppendLiteral("Failure processing schema, cannot clone "); - errorMsg.AppendLiteral("attributes from base type \""); - errorMsg.Append(baseStr); - errorMsg.AppendLiteral("\""); - - NS_SCHEMALOADER_FIRE_ERROR(rv, errorMsg); - - return rv; - } - - rv = aComplexType->AddAttribute(attribute); - if (NS_FAILED(rv)) { - nsAutoString errorMsg; - errorMsg.AppendLiteral("Failure processing schema, cannot clone "); - errorMsg.AppendLiteral("attributes from base type \""); - errorMsg.Append(baseStr); - errorMsg.AppendLiteral("\""); - - NS_SCHEMALOADER_FIRE_ERROR(rv, errorMsg); - - return rv; - } } } @@ -2201,6 +2165,46 @@ nsSchemaLoader::ProcessComplexContent(nsIWebServiceErrorHandler* aErrorHandler, *aContentModel = explicitContent; } } + + // Copy over the attributes from the base type + // XXX Should really be cloning + if (complexBaseType) { + PRUint32 attrIndex, attrCount; + complexBaseType->GetAttributeCount(&attrCount); + + for (attrIndex = 0; attrIndex < attrCount; attrIndex++) { + nsCOMPtr attribute; + + rv = complexBaseType->GetAttributeByIndex(attrIndex, + getter_AddRefs(attribute)); + if (NS_FAILED(rv)) { + nsAutoString errorMsg; + errorMsg.AppendLiteral("Failure processing schema, cannot clone "); + errorMsg.AppendLiteral("attributes from base type \""); + errorMsg.Append(baseStr); + errorMsg.AppendLiteral("\""); + + NS_SCHEMALOADER_FIRE_ERROR(rv, errorMsg); + + return rv; + } + + rv = aComplexType->AddAttribute(attribute); + if (NS_FAILED(rv)) { + nsAutoString errorMsg; + errorMsg.AppendLiteral("Failure processing schema, cannot clone "); + errorMsg.AppendLiteral("attributes from base type \""); + errorMsg.Append(baseStr); + errorMsg.AppendLiteral("\""); + + NS_SCHEMALOADER_FIRE_ERROR(rv, errorMsg); + + return rv; + } + } + } + + break; } }