nsresult rv; nsCOMPtr<nsIAtom>       tag; nsCOMPtr<nsIDocument>   doc; nsCOMPtr<nsIAtom>       rootAtom; if (NS_FAILED(rv = GetRootWidgetAtom(getter_AddRefs(rootAtom)))) { return rv; }  if (NS_FAILED(rv = mDocument->QueryInterface(kIDocumentIID, (void**) getter_AddRefs(doc)))) return rv;   if ((tag = dont_AddRef(NS_NewAtom("document"))) == nsnull) return NS_ERROR_OUT_OF_MEMORY;  nsCOMPtr<nsIContent> root; if (NS_FAILED(rv = NS_NewRDFElement(kNameSpaceID_HTML,  tag, getter_AddRefs(root)))) return rv;  doc->SetRootContent(NS_STATIC_CAST(nsIContent*, root));   nsCOMPtr<nsIContent> body; if ((tag = dont_AddRef(NS_NewAtom("body"))) == nsnull) return NS_ERROR_OUT_OF_MEMORY;  if (NS_FAILED(rv = NS_NewRDFElement(kNameSpaceID_HTML,  tag, getter_AddRefs(body)))) return rv;    if (NS_FAILED(rv = root->AppendChildTo(body, PR_FALSE))) return rv;    nsCOMPtr<nsIContent> widget; if (NS_FAILED(rv = CreateResourceElement(kNameSpaceID_XUL, rootAtom, aResource, getter_AddRefs(widget)))) return rv;  if (NS_FAILED(rv = widget->SetAttribute(kNameSpaceID_RDF, kContainerAtom, "true", PR_FALSE))) return rv;   if (NS_FAILED(rv = body->AppendChildTo(widget, PR_FALSE))) return rv;  return NS_OK;
NS_NOTREACHED("whoops"); return NS_ERROR_UNEXPECTED;
RDFGenericBuilderImpl::CreateRootContent(nsIRDFResource* aResource){    // Create a structure that looks like this:    //    // <html:document>    //    <html:body>    //       <xul:rootwidget>    //       </xul:rootwidget>    //    </html:body>    // </html:document>    //    // Eventually, we should be able to do away with the HTML tags and    // just have it create XUL in some other context.    nsresult rv;    nsCOMPtr<nsIAtom>       tag;    nsCOMPtr<nsIDocument>   doc;    nsCOMPtr<nsIAtom>       rootAtom;    if (NS_FAILED(rv = GetRootWidgetAtom(getter_AddRefs(rootAtom)))) {        return rv;    }    if (NS_FAILED(rv = mDocument->QueryInterface(kIDocumentIID,                                                 (void**) getter_AddRefs(doc))))        return rv;    // Create the DOCUMENT element    if ((tag = dont_AddRef(NS_NewAtom("document"))) == nsnull)        return NS_ERROR_OUT_OF_MEMORY;    nsCOMPtr<nsIContent> root;    if (NS_FAILED(rv = NS_NewRDFElement(kNameSpaceID_HTML, /* XXX */                                        tag,                                        getter_AddRefs(root))))        return rv;    doc->SetRootContent(NS_STATIC_CAST(nsIContent*, root));    // Create the BODY element    nsCOMPtr<nsIContent> body;    if ((tag = dont_AddRef(NS_NewAtom("body"))) == nsnull)        return NS_ERROR_OUT_OF_MEMORY;    if (NS_FAILED(rv = NS_NewRDFElement(kNameSpaceID_HTML, /* XXX */                                        tag,                                        getter_AddRefs(body))))        return rv;    // Attach the BODY to the DOCUMENT    if (NS_FAILED(rv = root->AppendChildTo(body, PR_FALSE)))        return rv;    // Create the xul:rootwidget element, and indicate that children should    // be recursively generated on demand    nsCOMPtr<nsIContent> widget;    if (NS_FAILED(rv = CreateResourceElement(kNameSpaceID_XUL,                                             rootAtom,                                             aResource,                                             getter_AddRefs(widget))))        return rv;    if (NS_FAILED(rv = widget->SetAttribute(kNameSpaceID_RDF, kContainerAtom, "true", PR_FALSE)))        return rv;    // Attach the ROOTWIDGET to the BODY    if (NS_FAILED(rv = body->AppendChildTo(widget, PR_FALSE)))        return rv;    return NS_OK;}