NS_WARNING("changing an rdf: attribute; this is probably not a good thing");
PR_LOG(gLog, PR_LOG_ALWAYS, ("changing an rdf: attribute; this is probably not a good thing"));
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_FAILED(rv = mDB->HasAssertion(resource,                                         kRDF_instanceOf,                                         kXUL_element,                                         PR_TRUE,                                         &isXULElement))) {        NS_ERROR("unable to determine if element is a XUL element");        return rv;    }    if (! isXULElement)        return NS_OK;    // Okay, so it _is_ a XUL element. Deal with it.    // 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;    }    // Check for "special" properties that may wreak havoc on the    // content model.    if ((nameSpaceID == kNameSpaceID_None) && (nameAtom.get() == kIdAtom)) {        // They're changing the ID of the element.        // XXX Punt for now.        NS_WARNING("ignoring id change on XUL element");        return NS_OK;    }    else if (nameSpaceID == kNameSpaceID_RDF) {        if (nameAtom.get() == kDataSourcesAtom) {            NS_NOTYETIMPLEMENTED("can't change the data sources yet");            return NS_ERROR_NOT_IMPLEMENTED;        }        // XXX we should probably just ignore any changes to rdf: attribute        NS_WARNING("changing an rdf: attribute; this is probably not a good thing");        return NS_OK;    }    // If we get here, it's a vanilla property that we need to go into    // the RDF graph to update. So, build an RDF resource from the    // property name...    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;        }        rv = mDB->Assert(resource, property, value, PR_TRUE);        NS_ASSERTION(rv == NS_RDF_ASSERTION_ACCEPTED, "unable to assert new property value");        if (NS_FAILED(rv)) return rv;    }    return NS_OK;}