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;   rv = SynchronizeUsingTemplate(templateNode, element, eClear, aProperty, aTarget); if (NS_FAILED(rv)) return rv; }
RDFGenericBuilderImpl::OnUnassert(nsIRDFResource* aSubject,                                  nsIRDFResource* aPredicate,                                  nsIRDFNode* aObject){    NS_PRECONDITION(mDocument != nsnull, "not initialized");    if (! mDocument)        return NS_ERROR_NOT_INITIALIZED;    nsresult rv;    nsCOMPtr<nsISupportsArray> elements;    if (NS_FAILED(rv = NS_NewISupportsArray(getter_AddRefs(elements)))) {        NS_ERROR("unable to create new ISupportsArray");        return rv;    }    // Find all the elements in the content model that correspond to    // aSubject: for each, we'll try to build XUL children if    // appropriate.    if (NS_FAILED(rv = mDocument->GetElementsForResource(aSubject, elements))) {        NS_ERROR("unable to retrieve elements from resource");        return rv;    }    for (PRInt32 i = elements->Count() - 1; i >= 0; --i) {        nsCOMPtr<nsIContent> element( do_QueryInterface(elements->ElementAt(i)) );                // 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;        if (NS_SUCCEEDED(aObject->QueryInterface(kIRDFResourceIID,                                                 (void**) getter_AddRefs(resource)))            && IsContainmentProperty(element, aPredicate)) {            // Okay, the object _is_ a resource, and the predicate is            // a containment property. So this'll be a new item in the widget            // control.            // 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;            if (NS_FAILED(rv = element->GetAttribute(kNameSpaceID_None,                                                     kItemContentsGeneratedAtom,                                                     contentsGenerated))) {                NS_ERROR("severe problem trying to get attribute");                return rv;            }            if ((rv == NS_CONTENT_ATTR_HAS_VALUE) &&                contentsGenerated.EqualsIgnoreCase("true")) {                // Okay, it's a "live" element, so go ahead and append the new                // child to this node.                if (NS_FAILED(rv = RemoveWidgetItem(element, aPredicate, resource))) {                    NS_ERROR("unable to create new widget item");                    return rv;                }            }        }        else {            // Either the object of the assertion is not a resource,            // or the object is a resource and the predicate is not a            // tree property. So this won't be a new row in the            // table. See if we can use it to set a cell value on the            // current element.            /* XXX: WHAT THE HECK IS THIS HERE FOR? - Dave            if (NS_FAILED(rv = SetCellValue(element, aPredicate, aObject))) {                NS_ERROR("unable to set cell value");                return rv;            }*/        }    }    return NS_OK;}