rv = NS_NewRDFElement(aNameSpaceID, aTag, getter_AddRefs(element));
rv = nsXULElement::Create(aNameSpaceID, aTag, getter_AddRefs(element));
XULContentSinkImpl::CreateXULElement(PRInt32 aNameSpaceID, nsIAtom* aTag, nsCOMPtr<nsIContent>* aResult){    nsresult rv;    nsCOMPtr<nsIContent> element;    rv = NS_NewRDFElement(aNameSpaceID, aTag, getter_AddRefs(element));    NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create new content element");    if (NS_FAILED(rv)) return rv;    rv = element->SetDocument(mDocument, PR_FALSE);    if (NS_FAILED(rv)) return rv;    // Initialize the element's containing namespace to that of its    // parent.    nsCOMPtr<nsIXMLContent> xml( do_QueryInterface(element) );    NS_ASSERTION(xml != nsnull, "not an XML element");    if (! xml)        return NS_ERROR_UNEXPECTED;    nsCOMPtr<nsINameSpace> ns;    rv = GetTopNameSpace(&ns);    if (NS_FAILED(rv)) return rv;    rv = xml->SetContainingNameSpace(ns);    if (NS_FAILED(rv)) return rv;    // Set the XML tag info: namespace prefix and ID. We do this    // _after_ processing all the attributes so that we can extract an    // appropriate prefix based on whatever namespace decls are    // active.    rv = xml->SetNameSpaceID(aNameSpaceID);    if (NS_FAILED(rv)) return rv;    if (aNameSpaceID != kNameSpaceID_None) {        nsCOMPtr<nsINameSpace> nameSpace;        rv = xml->GetContainingNameSpace(*getter_AddRefs(nameSpace));        if (NS_FAILED(rv)) return rv;        nsCOMPtr<nsIAtom> prefix;        rv = nameSpace->FindNameSpacePrefix(aNameSpaceID, *getter_AddRefs(prefix));        if (NS_FAILED(rv)) return rv;        rv = xml->SetNameSpacePrefix(prefix);        if (NS_FAILED(rv)) return rv;    }    // We also need to pay special attention to the keyset tag to set up a listener    //    // XXX shouldn't this be done in SetAttribute() or something?    if((aNameSpaceID == kNameSpaceID_XUL) && (aTag == kKeysetAtom)) {        // Create our nsXULKeyListener and hook it up.        nsCOMPtr<nsIXULKeyListener> keyListener;        rv = nsComponentManager::CreateInstance(kXULKeyListenerCID,                                                nsnull,                                                NS_GET_IID(nsIXULKeyListener),                                                getter_AddRefs(keyListener));        NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create a key listener");        if (NS_FAILED(rv)) return rv;                nsCOMPtr<nsIDOMEventListener> domEventListener = do_QueryInterface(keyListener);        if (domEventListener) {            // Take the key listener and add it as an event listener for keypress events.            nsCOMPtr<nsIDOMDocument> domDocument = do_QueryInterface(mDocument);            // Init the listener with the keyset node            nsCOMPtr<nsIDOMElement> domElement = do_QueryInterface(element);            keyListener->Init(domElement, domDocument);                        nsCOMPtr<nsIDOMEventReceiver> receiver = do_QueryInterface(mDocument);            if(receiver) {                receiver->AddEventListener("keypress", domEventListener, PR_TRUE);                 receiver->AddEventListener("keydown",  domEventListener, PR_TRUE);                  receiver->AddEventListener("keyup",    domEventListener, PR_TRUE);               }        }    }    *aResult = element;    return NS_OK;}