NS_PRECONDITION(mRootContent != nsnull, "document contains no content"); if (! mRootContent) return NS_ERROR_NOT_INITIALIZED;
XULDocumentImpl::GetElementById(const nsString& aId, nsIDOMElement** aReturn){    nsresult rv;    nsAutoString uri(aId);    const char* documentURL;    mDocumentURL->GetSpec(&documentURL);    rdf_PossiblyMakeAbsolute(documentURL, uri);    nsCOMPtr<nsIRDFResource> resource;    if (NS_FAILED(rv = mRDFService->GetUnicodeResource(uri, getter_AddRefs(resource)))) {        NS_ERROR("unable to get resource");        return rv;    }    nsCOMPtr<nsISupportsArray> elements;    if (NS_FAILED(rv = NS_NewISupportsArray(getter_AddRefs(elements)))) {        NS_ERROR("unable to create new ISupportsArray");        return rv;    }    if (NS_FAILED(rv = GetElementsForResource(resource, elements))) {        NS_ERROR("unable to get elements for resource");        return rv;    }    if (elements->Count() > 0) {        if (elements->Count() > 1) {            // This is a scary case that our API doesn't deal with well.            NS_WARNING("more than one element found with specified ID; returning first");        }        nsISupports* element = elements->ElementAt(0);        rv = element->QueryInterface(nsIDOMElement::GetIID(), (void**) aReturn);        NS_ASSERTION(NS_SUCCEEDED(rv), "not a DOM element");        NS_RELEASE(element);        return rv;    }    // Didn't find it in our hash table. Walk the tree looking for the    // node. This happens for elements that aren't nsRDFElement    // objects (e.g., HTML content).    *aReturn = nsnull;    SearchForNodeByID(aId, mRootContent, aReturn);    return NS_OK;}