info1->resource = res1;
XULSortServiceImpl::GetNodeValue(contentSortInfo *info1, sortPtr sortInfo, PRBool first,                                 PRBool onlyCollationHint, nsIRDFNode **theNode,                                 PRBool &isCollationKey){  nsresult rv = NS_OK;  nsCOMPtr<nsIRDFResource>  res1;  nsIContent *node1 = info1->content;  *theNode = nsnull;  isCollationKey = PR_FALSE;  // determine the rdf resource  nsCOMPtr<nsIDOMXULElement>  dom1 = do_QueryInterface(node1);  if (dom1)    res1 = info1->resource;  else {    // If this isn't a XUL element, get its id and fetch the resource directly    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, getter_AddRefs(res1))))          res1 = nsnull;        info1->resource = res1;      }    }    else      return NS_ERROR_FAILURE;  }    if ((!sortInfo->naturalOrderSort) && (sortInfo->sortProperty)) {    if (res1) {      rv = GetResourceValue(info1, sortInfo, first, PR_TRUE, onlyCollationHint, theNode, isCollationKey);      if ((rv == NS_RDF_NO_VALUE) || (!*theNode)) {        rv = GetResourceValue(info1, 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;        }      }    }  }  else    // XXX Is this right?    rv = NS_ERROR_NULL_POINTER;  return rv;}