nsCOMPtr<nsIDocument> doc; mRoot->GetDocument(getter_AddRefs(doc)); NS_ASSERTION(doc != nsnull, "root element not in document"); if (! doc) return NS_ERROR_FAILURE;  nsCOMPtr<nsIXULDocument> xuldoc = do_QueryInterface(doc); NS_ASSERTION(xuldoc != nsnull, "expected a XUL document");
nsCOMPtr<nsIXULDocument> xuldoc = do_QueryInterface(mRoot->GetDocument()); NS_ASSERTION(xuldoc, "expected a XUL document");
nsXULContentBuilder::GetElementsForResource(nsIRDFResource* aResource, nsISupportsArray* aElements){    const char *uri;    aResource->GetValueConst(&uri);    nsCOMPtr<nsIDocument> doc;    mRoot->GetDocument(getter_AddRefs(doc));    NS_ASSERTION(doc != nsnull, "root element not in document");    if (! doc)        return NS_ERROR_FAILURE;    nsCOMPtr<nsIXULDocument> xuldoc = do_QueryInterface(doc);    NS_ASSERTION(xuldoc != nsnull, "expected a XUL document");    if (! xuldoc)        return NS_ERROR_FAILURE;    return xuldoc->GetElementsForID(NS_ConvertUTF8toUCS2(uri), aElements);}