if ((rv != NS_CONTENT_ATTR_HAS_VALUE) || !contentsGenerated.EqualsIgnoreCase("true"))
if (! contentsGenerated)
RDFGenericBuilderImpl::OnUnassert(nsIRDFResource* aSource,                                  nsIRDFResource* aProperty,                                  nsIRDFNode* aTarget){	// Just silently fail, because this can happen "normally" as part	// of tear-down code. (Bug 9098)    if (! mDocument)        return NS_OK;    nsresult rv;    nsCOMPtr<nsISupportsArray> elements;    rv = NS_NewISupportsArray(getter_AddRefs(elements));	NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create new ISupportsArray");	if (NS_FAILED(rv)) return rv;    // Find all the elements in the content model that correspond to    // aSource: for each, we'll try to build XUL children if    // appropriate.    rv = mDocument->GetElementsForResource(aSource, elements);	NS_ASSERTION(NS_SUCCEEDED(rv), "unable to retrieve elements from resource");	if (NS_FAILED(rv)) return rv;    PRUint32 cnt;    rv = elements->Count(&cnt);    if (NS_FAILED(rv)) return rv;    for (PRInt32 i = cnt - 1; i >= 0; --i) {		nsISupports* isupports = elements->ElementAt(i);        nsCOMPtr<nsIContent> element( do_QueryInterface(isupports) );		NS_IF_RELEASE(isupports);                // XXX somehow figure out if building XUL kids on this        // particular element makes any sense whatsoever.        // We'll start by making sure that the element at least has        // the same parent has the content model builder's root        if (!IsElementInWidget(element))            continue;                nsCOMPtr<nsIRDFResource> resource = do_QueryInterface(aTarget);        if (resource && IsContainmentProperty(element, aProperty)) {            // Okay, the object _is_ a resource, and the predicate is            // a containment property. So we'll need to remove this            // item from the widget.            // But if the contents of aElement _haven't_ yet been            // generated, then just ignore the unassertion: nothing is            // in the content model to remove.            nsAutoString contentsGenerated;            rv = element->GetAttribute(kNameSpaceID_None,                                       kContainerContentsGeneratedAtom,                                       contentsGenerated);            if (NS_FAILED(rv)) return rv;            if ((rv != NS_CONTENT_ATTR_HAS_VALUE) || !contentsGenerated.EqualsIgnoreCase("true"))                return NS_OK;            // Okay, it's a "live" element, so go ahead and remove the            // child from this node.            rv = RemoveWidgetItem(element, aProperty, resource);            NS_ASSERTION(NS_SUCCEEDED(rv), "unable to remove widget item");            if (NS_FAILED(rv)) return rv;		PRInt32	numKids;		if (NS_SUCCEEDED(element->ChildCount(numKids)) && (numKids == 0))		{			nsAutoString		emptyVal("true");			element->SetAttribute(kNameSpaceID_None, kEmptyAtom, emptyVal, PR_TRUE);		}                    }        else {            // Either the target of the assertion is not a resource,            // or the target is a resource and the property is not a            // containment property. So this won't be an item in the            // widget. See if we need to tear down some substructure            // on the current element.            nsAutoString templateID;            rv = element->GetAttribute(kNameSpaceID_None,                                       kTemplateAtom,                                       templateID);            if (NS_FAILED(rv)) return rv;            if (rv == NS_CONTENT_ATTR_HAS_VALUE) {				nsCOMPtr<nsIDOMXULDocument>	xulDoc;				xulDoc = do_QueryInterface(mDocument);                if (! xulDoc)                    return NS_ERROR_UNEXPECTED;				nsCOMPtr<nsIDOMElement>	domElement;                rv = xulDoc->GetElementById(templateID, getter_AddRefs(domElement));                NS_ASSERTION(NS_SUCCEEDED(rv), "unable to find template node");                if (NS_FAILED(rv)) return rv;				nsCOMPtr<nsIContent> templateNode = do_QueryInterface(domElement);                if (! templateNode)                    return NS_ERROR_UNEXPECTED;                // this node was created by a XUL template, so update it accordingly                rv = SynchronizeUsingTemplate(templateNode, element, eClear, aProperty, aTarget);                if (NS_FAILED(rv)) return rv;            }#ifdef FALLBACK_BUILDERS            else {                rv = UnsetWidgetAttribute(element, aProperty, aTarget);                if (NS_FAILED(rv)) return rv;            }#endif        }    }    return NS_OK;}