aEncoding->GetSchemaCollection(getter_AddRefs(collection)); if (NS_FAILED(rc)) return rc;
aEncoding->GetSchemaCollection(getter_AddRefs(collection)); NS_ENSURE_SUCCESS(rc, rc);
    nsDefaultEncoder::Decode(nsISOAPEncoding * aEncoding,                             nsIDOMElement * aSource,                             nsISchemaType * aSchemaType,                             nsISOAPAttachments * aAttachments,                             nsIVariant ** _retval){  NS_ENSURE_ARG_POINTER(aEncoding);  NS_ENSURE_ARG_POINTER(aSource);  NS_ENSURE_ARG_POINTER(_retval);  *_retval = nsnull;  nsCOMPtr < nsISOAPEncoding > encoding = aEncoding;        //  First, handle encoding redesignation, if any  {    nsCOMPtr < nsIDOMAttr > enc;    nsresult rv =        aSource->        GetAttributeNodeNS(*nsSOAPUtils::kSOAPEnvURI[mSOAPVersion],                           nsSOAPUtils::kEncodingStyleAttribute,                           getter_AddRefs(enc));    if (NS_FAILED(rv))      return rv;    if (enc) {      nsAutoString oldstyle;      rv = encoding->GetStyleURI(oldstyle);      if (NS_FAILED(rv))        return rv;      nsAutoString style;      rv = enc->GetNodeValue(style);      if (NS_FAILED(rv))        return rv;      if (!style.Equals(oldstyle)) {        nsCOMPtr < nsISOAPEncoding > newencoding;        rv = encoding->GetAssociatedEncoding(style, PR_FALSE,                                             getter_AddRefs(newencoding));        if (NS_FAILED(rv))          return rv;        if (newencoding) {          return newencoding->Decode(aSource, aSchemaType, aAttachments, _retval);        }      }    }  }  //  Handle xsi:null="true"  nsAutoString nullstr;  if (nsSOAPUtils::GetAttribute(aEncoding, aSource, nsSOAPUtils::kXSIURI, kNull, nullstr)) {    if (nullstr.Equals(nsSOAPUtils::kTrue)             || nullstr.Equals(nsSOAPUtils::kTrueA)) {      *_retval = nsnull;      return NS_OK;    }    else if (!(nullstr.Equals(nsSOAPUtils::kFalse)             || nullstr.Equals(nsSOAPUtils::kFalseA)))      return SOAP_EXCEPTION(NS_ERROR_ILLEGAL_VALUE,"SOAP_NILL_VALUE","The value of the nill attribute must be true or false.");  }  nsCOMPtr < nsISchemaType > type = aSchemaType;  nsCOMPtr < nsISOAPDecoder > decoder;  //  All that comes out of this block is decoder, type, and some checks.  {                        //  Look up type element and schema attribute, if possible    nsCOMPtr < nsISchemaType > subType;    nsCOMPtr < nsISchemaCollection > collection;    nsresult rc =        aEncoding->GetSchemaCollection(getter_AddRefs(collection));    if (NS_FAILED(rc))      return rc;    nsAutoString ns;    nsAutoString name;    rc = aSource->GetNamespaceURI(name);    if (NS_FAILED(rc))      return rc;    rc = aEncoding->GetInternalSchemaURI(name, ns);    if (NS_FAILED(rc))      return rc;    rc = aSource->GetLocalName(name);    if (NS_FAILED(rc))      return rc;    nsCOMPtr < nsISchemaElement > element;    rc = collection->GetElement(name, ns, getter_AddRefs(element));//      if (NS_FAILED(rc)) return rc;    if (element) {      rc = element->GetType(getter_AddRefs(subType));      if (NS_FAILED(rc))        return rc;    } else {      nsAutoString internal;      rc = aEncoding->GetInternalSchemaURI(ns, internal);      if (NS_FAILED(rc))        return rc;      if (internal.Equals(nsSOAPUtils::kSOAPEncURI)) {        //  Last-ditch hack to get undeclared types from SOAP namespace        if (name.Equals(kArraySOAPType)            || name.Equals(kStructSOAPType)) {        //  This should not be needed if schema has these declarations          rc = collection->GetType(name, internal, getter_AddRefs(subType));        } else {          rc = collection->GetType(name,                                   nsSOAPUtils::kXSURI,                                   getter_AddRefs(subType));        }      }//        if (NS_FAILED(rc)) return rc;    }    if (!subType)      subType = type;    nsCOMPtr < nsISchemaType > subsubType;    nsAutoString explicitType;    if (nsSOAPUtils::GetAttribute(aEncoding, aSource, nsSOAPUtils::kXSIURI,                                 nsSOAPUtils::kXSITypeAttribute,                                 explicitType)) {      rc = nsSOAPUtils::GetNamespaceURI(aEncoding, aSource, explicitType, ns);      if (NS_FAILED(rc))        return rc;      rc = nsSOAPUtils::GetLocalName(explicitType, name);      if (NS_FAILED(rc))        return rc;      rc = collection->GetType(name, ns, getter_AddRefs(subsubType));//      if (NS_FAILED(rc)) return rc;    }    if (!subsubType)      subsubType = subType;      if (subsubType) {  //  Loop up the hierarchy, to check and look for decoders      for(;;) {        nsCOMPtr < nsISchemaType > lookupType = subsubType;        do {          if (lookupType == subType) {  //  Tick off the located super classes            subType = nsnull;          }          if (lookupType == type) {  //  Tick off the located super classes            type = nsnull;          }          if (!decoder) {            nsAutoString schemaType;            nsAutoString schemaURI;            nsresult rc = lookupType->GetName(schemaType);            if (NS_FAILED(rc))              return rc;            rc = lookupType->GetTargetNamespace(schemaURI);            if (NS_FAILED(rc))              return rc;            nsAutoString encodingKey;            SOAPEncodingKey(schemaURI, schemaType, encodingKey);            rc = aEncoding->GetDecoder(encodingKey, getter_AddRefs(decoder));            if (NS_FAILED(rc))              return rc;          }          nsCOMPtr<nsISchemaType> supertype;          rc = GetSupertype(aEncoding, lookupType, getter_AddRefs(supertype));          if (NS_FAILED(rc))            return rc;          lookupType = supertype;        } while (lookupType);        if (!type) {          type = subsubType;          break;        }        decoder = nsnull;        if (!subType) {          subType = type;        }        subsubType = subType;      }    }  }  if (!decoder) {    PRBool simple = PR_TRUE;    if (type) {      nsresult rc = HasSimpleValue(type, &simple);      if (NS_FAILED(rc))        return rc;    }    if (simple) {      nsCOMPtr<nsIDOMElement> child;      nsSOAPUtils::GetFirstChildElement(aSource, getter_AddRefs(child));      simple = !child;    }    nsAutoString decodingKey;    if (!simple) {      SOAPEncodingKey(nsSOAPUtils::kSOAPEncURI,                      kStructSOAPType, decodingKey);    } else {      SOAPEncodingKey(nsSOAPUtils::kXSURI,                      kAnySimpleTypeSchemaType, decodingKey);    }    nsresult rc =      aEncoding->GetDecoder(decodingKey, getter_AddRefs(decoder));    if (NS_FAILED(rc))      return rc;  }  if (decoder) {    return decoder->Decode(aEncoding, aSource, type, aAttachments,                           _retval);  }  return SOAP_EXCEPTION(NS_ERROR_NOT_IMPLEMENTED,"SOAP_NO_DECODER_FOR_TYPE","The default decoder finds no decoder for specific type");}