return(rv);
else  rv = NS_ERROR_NULL_POINTER;  return rv;
XULSortServiceImpl::GetNodeValue(nsIContent *node1, sortPtr sortInfo, PRBool first,        PRBool onlyCollationHint, nsIRDFNode **theNode, PRBool &isCollationKey){  nsresult rv;  nsCOMPtr<nsIRDFResource>  res1;  *theNode = nsnull;  isCollationKey = PR_FALSE;  nsCOMPtr<nsIDOMXULElement>  dom1 = do_QueryInterface(node1);  if (dom1) {    if (NS_FAILED(rv = dom1->GetResource(getter_AddRefs(res1))))      res1 = nsnull;    // Note: don't check for res1 QI failure here.  It only succeeds for RDF nodes,    // but for XUL nodes it will failure; in the failure case, the code below gets    // the cell's text value straight from the DOM  } else {    nsCOMPtr<nsIDOMElement>  htmlDom = do_QueryInterface(node1);    if (htmlDom) {      nsAutoString htmlID;      if (NS_SUCCEEDED(rv = node1->GetAttr(kNameSpaceID_None, nsXULAtoms::id, htmlID))           && (rv == NS_CONTENT_ATTR_HAS_VALUE))      {        if (NS_FAILED(rv = gRDFService->GetUnicodeResource(htmlID.get(), getter_AddRefs(res1))))          res1 = nsnull;      }    }    else    {      return NS_ERROR_FAILURE;    }  }    if ((sortInfo->naturalOrderSort == PR_FALSE) && (sortInfo->sortProperty)) {    if (res1) {      rv = GetResourceValue(res1, sortInfo, first, PR_TRUE, onlyCollationHint, theNode, isCollationKey);      if ((rv == NS_RDF_NO_VALUE) || (!*theNode))        rv = GetResourceValue(res1, sortInfo, first, PR_FALSE, onlyCollationHint, theNode, isCollationKey);    }    else      rv = NS_RDF_NO_VALUE;  } else if ((sortInfo->naturalOrderSort == PR_TRUE) && (sortInfo->parentContainer)) {    nsAutoString    cellPosVal1;    // check to see if this is a RDF_Seq    // Note: this code doesn't handle the aggregated Seq case especially well    if ((res1) && (sortInfo->db))    {      nsCOMPtr<nsIRDFResource>  parentResource;      nsCOMPtr<nsIDOMXULElement>  parentDOMNode = do_QueryInterface(sortInfo->parentContainer);      if (parentDOMNode)      {        if (NS_FAILED(rv = parentDOMNode->GetResource(getter_AddRefs(parentResource))))        {          parentResource = nsnull;        }      }      if (parentResource)      {        PRInt32 index;        rv = gRDFC->IndexOf(sortInfo->db, parentResource,                res1, &index);        if (index != -1)        {          nsCOMPtr<nsIRDFInt> intLit;          rv = gRDFService->GetIntLiteral(index, getter_AddRefs(intLit));          CallQueryInterface(intLit, theNode);          isCollationKey = PR_FALSE;        }      }    }  }  return(rv);}