nsCOMPtr<nsIRDFResource> oldChild; if (NS_FAILED(rv = GetDOMNodeResource(aOldChild, getter_AddRefs(oldChild)))) { NS_ERROR("new child doesn't have a resource"); return rv; }
nsCOMPtr<nsIRDFNode> oldChild; rv = GetGraphNodeForXULElement(aOldChild, getter_AddRefs(oldChild)); if (NS_FAILED(rv)) return rv;  if (rv == NS_RDF_NO_VALUE) return NS_OK;
RDFXULBuilderImpl::OnRemoveChild(nsIDOMNode* aParent, nsIDOMNode* aOldChild){    NS_PRECONDITION(aParent != nsnull, "null ptr");    if (!aParent)        return NS_ERROR_NULL_POINTER;    NS_PRECONDITION(aOldChild != nsnull, "null ptr");    if (!aOldChild)        return NS_ERROR_NULL_POINTER;    nsresult rv;    // XXX may want to check _here_ to make sure that aOldChild is    // actually a child of aParent...    // XXX If aOldChild doesn't have a resource, then somebody is    // removing a non-RDF element from aParent. This probably isn't a    // big deal, but panic for now.    nsCOMPtr<nsIRDFResource> oldChild;    if (NS_FAILED(rv = GetDOMNodeResource(aOldChild, getter_AddRefs(oldChild)))) {        NS_ERROR("new child doesn't have a resource");        return rv;    }    // If the new parent has a resource...    nsCOMPtr<nsIRDFResource> parent;    if (NS_SUCCEEDED(rv = GetDOMNodeResource(aParent, getter_AddRefs(parent)))) {        // ...and it's a XUL element...        PRBool isXULElement;        if (NS_SUCCEEDED(rv = mDB->HasAssertion(parent,                                                kRDF_instanceOf,                                                kXUL_element,                                                PR_TRUE,                                                &isXULElement))            && isXULElement) {            // ...then remove it from the container            if (NS_FAILED(rv = rdf_ContainerRemoveElement(mDB, parent, oldChild))) {                NS_ERROR("unable to insert new element into container");                return rv;            }        }    }    return NS_OK;}