if (NS_SUCCEEDED(rv = (sortInfo->db)->GetTarget(res1, modSortRes, PR_TRUE, &target1)))
if (NS_SUCCEEDED(rv = (sortInfo->db)->GetTarget(res1, modSortRes, PR_TRUE, &target1)) && (rv != NS_RDF_NO_VALUE))
getNodeValue(nsIContent *node1, nsIRDFResource *sortProperty, sortPtr sortInfo, nsString &cellVal1){	nsIDOMXULElement	*dom1;	nsIRDFResource		*res1;	nsresult		rv;	cellVal1 = "";	if (NS_SUCCEEDED(rv = node1->QueryInterface(kIDomXulElementIID, (void **)&dom1)))	{		if (NS_SUCCEEDED(rv = dom1->GetResource(&res1)))		{			if ((sortInfo->naturalOrderSort == PR_FALSE) && (sortInfo->sortProperty))			{				nsIRDFNode	*target1 = nsnull;				// for any given property, first ask the graph for its value with "?sort=true" appended				// to indicate that if there is any distinction between its display value and sorting				// value, we want the sorting value (so that, for example, a mail datasource could strip				// off a "Re:" on a mail message subject)				nsXPIDLCString	sortPropertyURI;				sortInfo->sortProperty->GetValue( getter_Copies(sortPropertyURI) );				if (sortPropertyURI)				{					nsAutoString	modSortProperty(sortPropertyURI);					modSortProperty += "?sort=true";					char	*sortProp = modSortProperty.ToNewCString();					if (sortProp)					{						nsIRDFResource	*modSortRes = nsnull;						if (NS_SUCCEEDED(sortInfo->rdfService->GetResource(sortProp, &modSortRes)))						{							if (modSortRes)							{								if (NS_SUCCEEDED(rv = (sortInfo->db)->GetTarget(res1, modSortRes, PR_TRUE, &target1)))								{									nsIRDFLiteral *literal1;									if (NS_SUCCEEDED(target1->QueryInterface(kIRDFLiteralIID, (void **) &literal1)))									{										nsXPIDLString uniStr1;										literal1->GetValue( getter_Copies(uniStr1) );										cellVal1 = uniStr1;										NS_RELEASE(literal1);									}									NS_RELEASE(target1);								}								NS_RELEASE(modSortRes);							}						}						delete []sortProp;					}				}				if (cellVal1.Length() == 0)				{					if (NS_SUCCEEDED(rv = (sortInfo->db)->GetTarget(res1, sortProperty, PR_TRUE, &target1)))					{						nsIRDFLiteral *literal1;						if (NS_SUCCEEDED(target1->QueryInterface(kIRDFLiteralIID, (void **) &literal1)))						{							nsXPIDLString uniStr1;							literal1->GetValue( getter_Copies(uniStr1) );							cellVal1 = uniStr1;							NS_RELEASE(literal1);						}						NS_RELEASE(target1);					}					else					{					        nsIContent	*cell1 = nsnull;						if (NS_SUCCEEDED(rv = GetTreeCell(sortInfo, node1, sortInfo->colIndex, &cell1)))						{							if (cell1)							{								if (NS_SUCCEEDED(rv = GetTreeCellValue(sortInfo, cell1, cellVal1)))								{								}							}						}					}				}			}			else if (sortInfo->naturalOrderSort == PR_TRUE)			{				if (NS_OK == node1->GetAttribute(kNameSpaceID_None, sortInfo->kNaturalOrderPosAtom, cellVal1))				{				}			}			NS_RELEASE(res1);		}		NS_RELEASE(dom1);	}	return(rv);}