nsCOMPtr<nsIContent> container; PRBool isRoot = PR_FALSE;
rv = BuildContentFromTemplate(tmpl, aElement, PR_TRUE, aChild, aNaturalOrderPos, aNotify);
RDFGenericBuilderImpl::CreateWidgetItem(nsIContent *aElement,                                        nsIRDFResource *aProperty,                                        nsIRDFResource *aValue,                                        PRInt32 aNaturalOrderPos){	nsCOMPtr<nsIContent> tmpl;	nsresult		rv;	rv = FindTemplateForResource(aValue, getter_AddRefs(tmpl));    if (NS_FAILED(rv)) {#ifdef FALLBACK_BUILDERS		return AddWidgetItem(aElement, aProperty, aValue, aNaturalOrderPos);#else        return NS_OK;#endif    }    // The "container" node which will be used to build children.    nsCOMPtr<nsIContent> container;    PRBool isRoot = PR_FALSE;    // if template specifies a rootcontainment attribute, get it    // and determine if we are building children off of the root    nsAutoString rootAttrValue;    rv = tmpl->GetAttribute(kNameSpaceID_None,                            kRootcontainmentAtom,                            rootAttrValue);    if (NS_FAILED(rv)) return rv;    if (rv == NS_CONTENT_ATTR_HAS_VALUE) {        // XXX Ick. Can we remember this somehow?        nsCOMPtr<nsIAtom> rootAtom = NS_NewAtom(rootAttrValue);        if (! rootAtom) return NS_ERROR_OUT_OF_MEMORY;        PRInt32 nameSpaceID;        rv = aElement->GetNameSpaceID(nameSpaceID);        if (NS_FAILED(rv)) return rv;        if (nameSpaceID == kNameSpaceID_XUL) {            nsCOMPtr<nsIAtom>	tag;            rv = aElement->GetTag(*getter_AddRefs(tag));            if (NS_FAILED(rv)) return rv;            if (tag == rootAtom)                isRoot = PR_TRUE;        }    }    // if template specifies a subcontainment attribute, get it    // and make sure aElement contains it (if not the root).    if (! isRoot) {        nsAutoString	attrValue;        rv = tmpl->GetAttribute(kNameSpaceID_None,                                kSubcontainmentAtom,                                attrValue);        if (NS_FAILED(rv)) return rv;        if (rv == NS_CONTENT_ATTR_HAS_VALUE) {            // XXX Ick. Can we remember this somehow?            nsCOMPtr<nsIAtom> childrenAtom = NS_NewAtom(attrValue);            if (! childrenAtom) return NS_ERROR_OUT_OF_MEMORY;            rv = EnsureElementHasGenericChild(aElement,                                              kNameSpaceID_XUL,                                              childrenAtom,                                              getter_AddRefs(container));            if (NS_FAILED(rv)) return rv;        }    }    // Otherwise, just use the element as the root.    if (! container) {        container = dont_QueryInterface(aElement);    }    rv = BuildContentFromTemplate(tmpl,                                  container,                                  PR_TRUE,                                  aValue,                                  aNaturalOrderPos);	if (NS_SUCCEEDED(rv))	{		nsAutoString		emptyVal("false");		aElement->SetAttribute(kNameSpaceID_None, kEmptyAtom, emptyVal, PR_TRUE);	}	return rv;}