if (NS_FAILED(rv = CreateResourceElement(kNameSpaceID_XUL, kTempAtom, aValue, getter_AddRefs(tempNode)))) return(rv); if (NS_FAILED(rv = SetAllAttributesOnElement(tempNode, aValue))) return(rv);
nsCOMPtr<nsIContent> tmpl; rv = FindTemplate(aElement, aProperty, aChild, getter_AddRefs(tmpl)); if (NS_FAILED(rv)) return rv;
RDFGenericBuilderImpl::CreateWidgetItem(nsIContent *aElement, nsIRDFResource *aProperty,					nsIRDFResource *aValue, PRInt32 aNaturalOrderPos){	nsCOMPtr<nsIContent>	aTemplate, tempNode;	nsresult		rv;	if (NS_FAILED(rv = CreateResourceElement(kNameSpaceID_XUL, kTempAtom,		aValue, getter_AddRefs(tempNode))))		return(rv);	if (NS_FAILED(rv = SetAllAttributesOnElement(tempNode, aValue)))		return(rv);	if (NS_SUCCEEDED(rv = FindTemplateForElement(tempNode, getter_AddRefs(aTemplate))) &&		(aTemplate))	{		nsCOMPtr<nsIContent>	children = do_QueryInterface(aElement);		// if template specifies a subcontainment attribute, get it		// and make sure aElement contains it, otherwise use aElement		nsAutoString	attrValue;		if (NS_SUCCEEDED(rv = aTemplate->GetAttribute(kNameSpaceID_XUL,                              kSubcontainmentAtom, attrValue)) && (rv == NS_CONTENT_ATTR_HAS_VALUE))		{			nsCOMPtr<nsIAtom>	childrenAtom = NS_NewAtom(attrValue);			if (childrenAtom)			{				if (NS_SUCCEEDED(rv = EnsureElementHasGenericChild(aElement, kNameSpaceID_XUL,							childrenAtom, getter_AddRefs(children))))				{				}			}		}		rv = PopulateWidgetItemSubtree(aTemplate, aTemplate, children,				aElement, aProperty, aValue, aNaturalOrderPos);	}	else	{		rv = AddWidgetItem(aElement, aProperty, aValue, aNaturalOrderPos);	}	return(rv);}