if (NS_FAILED(rv = node->QueryInterface(kIContentIID, &contentNode)))	return(rv);
if (NS_FAILED(rv = node->QueryInterface(kIContentIID, (void**)&contentNode)))	return(rv);
XULSortServiceImpl::DoSort(nsIDOMNode* node, const nsString& sortResource){	printf("XULSortServiceImpl::DoSort entered!!!\n");	PRInt32		childIndex, colIndex, numChildren, treeBodyIndex;	nsIContent	*child, *contentNode, *treeNode, *treeBody, *treeParent;	nsresult	rv;	if (NS_FAILED(rv = node->QueryInterface(kIContentIID, &contentNode)))	return(rv);	printf("Success converting dom node to content node.\n");	if (NS_FAILED(rv = FindTreeElement(contentNode, &treeNode)))	return(rv);	printf("found tree element\n");	if (NS_FAILED(rv = GetSortColumnIndex(treeNode, sortResource, &colIndex)))	return(rv);	printf("Sort column index is %d.\n", (int)colIndex);					if (NS_FAILED(rv = FindTreeBodyElement(treeNode, &treeBody)))	return(rv);	printf("Found tree body.\n");		if (NS_FAILED(rv = treeBody->GetParent(treeParent)))	return(rv);	printf("Found tree parent.\n");	if (NS_FAILED(rv = treeParent->IndexOf(treeBody, treeBodyIndex)))	return(rv);	printf("Found index of tree body in tree parent.\n");	if (NS_FAILED(rv = treeParent->RemoveChildAt(treeBodyIndex, PR_TRUE)))	return(rv);	printf("Removed tree body from parent.\n");	if (NS_SUCCEEDED(rv = SortTreeChildren(treeBody, colIndex, 0)))	{		printf("Tree sorted.\n");	}	if (NS_SUCCEEDED(rv = treeBody->UnsetAttribute(kNameSpaceID_None,		kTreeContentsGeneratedAtom,PR_FALSE)))	{	}	if (NS_SUCCEEDED(rv = treeParent->UnsetAttribute(kNameSpaceID_None,		kTreeContentsGeneratedAtom,PR_FALSE)))	{	}	if (NS_FAILED(rv = treeParent->AppendChildTo(treeBody, PR_TRUE)))	return(rv);	printf("Added tree body back into parent.\n");#if 0	if (NS_FAILED(rv = PrintTreeChildren(treeBody, colIndex, 0)))	return(rv);	printf("Tree printed.\nDone.\n");#endif	return(NS_OK);}