if (tagName && tagName.get() == kObservesAtom) {
if (mDocument && tagName && tagName.get() == kObservesAtom) {
RDFElementImpl::SetParent(nsIContent* aParent){    nsCOMPtr<nsIAtom> tagName;    GetTag(*getter_AddRefs(tagName));    mParent = aParent; // no refcount    // If we're an observes node, then we need to add our parent element    // as a broadcast listener.    if (tagName && tagName.get() == kObservesAtom) {      // Find the node that we're supposed to be      // observing and perform the hookup.      nsAutoString elementValue;      nsAutoString attributeValue;            GetAttribute("element",                   elementValue);            GetAttribute("attribute",                   attributeValue);      nsCOMPtr<nsIDOMXULDocument> xulDocument( do_QueryInterface(mDocument) );      nsCOMPtr<nsIDOMElement> domElement;      xulDocument->GetElementById(elementValue, getter_AddRefs(domElement));            if (domElement) {        // We have a DOM element to bind to.  Add a broadcast        // listener to that element, but only if it's a XUL element.        // XXX: Handle context nodes.        nsCOMPtr<nsIDOMNode> parentElement = do_QueryInterface(aParent);        nsCOMPtr<nsIDOMXULElement> broadcaster( do_QueryInterface(domElement) );        nsCOMPtr<nsIDOMElement> listener( do_QueryInterface(parentElement) );                if (listener)        {            broadcaster->AddBroadcastListener(attributeValue,                                              listener);        }      }    }    return NS_OK;}