if (NS_OK == child->GetAttribute(kNameSpaceID_RDF, kResourceAtom, colResource))
if (NS_SUCCEEDED(rv= child->GetAttribute(kNameSpaceID_RDF, kResourceAtom, colResource)) && (rv == NS_CONTENT_ATTR_HAS_VALUE))
XULSortServiceImpl::GetSortColumnIndex(nsIContent *tree, const nsString& sortResource, const nsString& sortDirection, PRInt32 *sortColIndex){	PRBool			found = PR_FALSE;	PRInt32			childIndex, colIndex = 0, numChildren, nameSpaceID;        nsCOMPtr<nsIContent>	child;	nsresult		rv;	*sortColIndex = 0;	if (NS_FAILED(rv = tree->ChildCount(numChildren)))	return(rv);	for (childIndex=0; childIndex<numChildren; childIndex++)	{		if (NS_FAILED(rv = tree->ChildAt(childIndex, *getter_AddRefs(child))))	return(rv);		if (NS_FAILED(rv = child->GetNameSpaceID(nameSpaceID)))	return(rv);		if (nameSpaceID == kNameSpaceID_XUL)		{			nsCOMPtr<nsIAtom> tag;			if (NS_FAILED(rv = child->GetTag(*getter_AddRefs(tag))))				return rv;			if (tag.get() == kTreeColAtom)			{				nsString	colResource;				if (NS_OK == child->GetAttribute(kNameSpaceID_RDF, kResourceAtom, colResource))				{					PRBool		setFlag = PR_FALSE;					if (colResource == sortResource)					{						*sortColIndex = colIndex;						found = PR_TRUE;						if (!sortDirection.EqualsIgnoreCase("natural"))						{							setFlag = PR_TRUE;						}					}					if (setFlag == PR_TRUE)					{						nsString	trueStr("true");						child->SetAttribute(kNameSpaceID_None, kSortAtom, trueStr, PR_TRUE);						child->SetAttribute(kNameSpaceID_None, kSortDirectionAtom, sortDirection, PR_TRUE);						// Note: don't break out of loop; want to set/unset attribs on ALL sort columns						// break;					}					else					{						child->UnsetAttribute(kNameSpaceID_None, kSortAtom, PR_TRUE);						child->UnsetAttribute(kNameSpaceID_None, kSortDirectionAtom, PR_TRUE);					}				}				++colIndex;			}		}	}	return((found == PR_TRUE) ? NS_OK : NS_ERROR_FAILURE);}