pAttributeAtom,
kAttributeAtom,
XULDocumentImpl::CreateContents(nsIContent* aElement){    NS_PRECONDITION(aElement != nsnull, "null ptr");    if (! aElement)        return NS_ERROR_NULL_POINTER;    if (! mBuilders)        return NS_ERROR_NOT_INITIALIZED;    for (PRUint32 i = 0; i < mBuilders->Count(); ++i) {        // XXX we should QueryInterface() here        nsIRDFContentModelBuilder* builder            = (nsIRDFContentModelBuilder*) mBuilders->ElementAt(i);        NS_ASSERTION(builder != nsnull, "null ptr");        if (! builder)            continue;        nsresult rv = builder->CreateContents(aElement);        NS_ASSERTION(NS_SUCCEEDED(rv), "error creating content");        // XXX ignore error code?        NS_RELEASE(builder);    }    // Now that the contents have been created, perform broadcaster    // hookups if any of the children are observes nodes.    // XXX: Initial sync-up doesn't work, since no document observer exists    // yet.    PRInt32 childCount;    aElement->ChildCount(childCount);    for (PRInt32 j = 0; j < childCount; j++)    {        nsIContent* pChildContent = nsnull;        aElement->ChildAt(j, pChildContent);              if (!pChildContent)          break;        nsIAtom* pTag = nsnull;        pChildContent->GetTag(pTag);        if (!pTag)          break;        nsString tagName;        pTag->ToString(tagName);        if (tagName.EqualsIgnoreCase("observes"))        {            // Find the node that we're supposed to be            // observing and perform the hookup.            nsIAtom* pElementAtom = NS_NewAtom("element");            nsIAtom* pAttributeAtom = NS_NewAtom("attribute");            nsString elementValue;            nsString attributeValue;            PRInt32 namespaceID = -1;                       pChildContent->GetNameSpaceID(namespaceID);            pChildContent->GetAttribute(namespaceID,                                         pElementAtom,                                        elementValue);                        pChildContent->GetAttribute(namespaceID,                                         pAttributeAtom,                                        attributeValue);            nsIDOMNode* pDOMNode = nsnull;            GetElementByID(elementValue, &pDOMNode);                        if (!pDOMNode)              break;            // We have a DOM node to bind to.  Add a broadcast            // listener to that node, but only if it's a XUL node.            // XXX: Handle context nodes.            nsCOMPtr<nsIDOMNode> pListener( do_QueryInterface(aElement) );            nsCOMPtr<nsIDOMXULElement> pBroadcaster( do_QueryInterface(pDOMNode) );            if (pListener)            {                pBroadcaster->AddBroadcastListener(attributeValue,                                                   pListener);            }            NS_RELEASE(pDOMNode);        }        NS_RELEASE(pChildContent);        NS_RELEASE(pTag);    }    return NS_OK;}