}   nsCOMPtr<nsIContent> element( do_QueryInterface(aElement) ); if (! element) { NS_ERROR("element doesn't support nsIContent"); return NS_ERROR_UNEXPECTED;
RDFXULBuilderImpl::OnSetAttribute(nsIDOMElement* aElement, const nsString& aName, const nsString& aValue){    nsresult rv;    nsCOMPtr<nsIRDFResource> resource;    if (NS_FAILED(rv = GetDOMNodeResource(aElement, getter_AddRefs(resource)))) {        // XXX it's not a resource element, so there's no assertions        // we need to make on the back-end. Should we just do the        // update?        return NS_OK;    }    // Make sure it's a XUL element; otherwise, we really don't have    // any business with the attribute.    PRBool isXULElement;    if (NS_SUCCEEDED(rv = mDB->HasAssertion(resource,                                            kRDF_instanceOf,                                            kXUL_element,                                            PR_TRUE,                                            &isXULElement))        && isXULElement) {        // Get the nsIContent interface, it's a bit more utilitarian        nsCOMPtr<nsIContent> element( do_QueryInterface(aElement) );        if (! element) {            NS_ERROR("element doesn't support nsIContent");            return NS_ERROR_UNEXPECTED;        }        // Split the property name into its namespace and tag components        PRInt32  nameSpaceID;        nsCOMPtr<nsIAtom> nameAtom;        if (NS_FAILED(rv = element->ParseAttributeString(aName, *getter_AddRefs(nameAtom), nameSpaceID))) {            NS_ERROR("unable to parse attribute string");            return rv;        }        nsCOMPtr<nsIRDFResource> property;        if (NS_FAILED(rv = GetResource(nameSpaceID, nameAtom, getter_AddRefs(property)))) {            NS_ERROR("unable to construct resource");            return rv;        }        // Unassert the old value, if there was one.        nsAutoString oldValue;        if (NS_CONTENT_ATTR_HAS_VALUE == element->GetAttribute(nameSpaceID, nameAtom, oldValue)) {            nsCOMPtr<nsIRDFLiteral> value;            if (NS_FAILED(rv = gRDFService->GetLiteral(oldValue, getter_AddRefs(value)))) {                NS_ERROR("unable to construct literal");                return rv;            }            rv = mDB->Unassert(resource, property, value);            NS_ASSERTION(NS_SUCCEEDED(rv), "unable to unassert old property value");        }        // Assert the new value        {            nsCOMPtr<nsIRDFLiteral> value;            if (NS_FAILED(rv = gRDFService->GetLiteral(aValue, getter_AddRefs(value)))) {                NS_ERROR("unable to construct literal");                return rv;            }            if (NS_FAILED(rv = mDB->Assert(resource, property, value, PR_TRUE))) {                NS_ERROR("unable to assert new property value");                return rv;            }        }    }        return NS_OK;}