rv = rdf_MakeSeq(mDocumentDataSource, resource); NS_ASSERTION(rv == NS_OK, "unable to mark as XUL element"); if (NS_FAILED(rv)) return rv;
{ NS_WITH_SERVICE(nsIRDFContainerUtils, rdfc, kRDFContainerUtilsCID, &rv); if (NS_FAILED(rv)) return rv;  rv = rdfc->MakeSeq(mDocumentDataSource, resource, nsnull); NS_ASSERTION(rv == NS_OK, "unable to mark as XUL element"); if (NS_FAILED(rv)) return rv; }
XULDocumentImpl::CreateElement(const nsString& aTagName, nsIDOMElement** aReturn){    NS_PRECONDITION(aReturn != nsnull, "null ptr");    if (! aReturn)        return NS_ERROR_NULL_POINTER;    // we need this so that we can create a resource URI    NS_PRECONDITION(mDocumentURL != nsnull, "not initialized");    if (! mDocumentURL)        return NS_ERROR_NOT_INITIALIZED;    nsresult rv;    nsCOMPtr<nsIAtom> name;    PRInt32 nameSpaceID;    // parse the user-provided string into a tag name and a namespace ID    rv = ParseTagString(aTagName, *getter_AddRefs(name), nameSpaceID);    NS_ASSERTION(NS_SUCCEEDED(rv), "unable to parse tag name");    if (NS_FAILED(rv)) return rv;    // construct an element    nsCOMPtr<nsIContent> result;    rv = NS_NewRDFElement(nameSpaceID, name, getter_AddRefs(result));    if (NS_FAILED(rv)) return rv;    // assign it an "anonymous" identifier so that it can be referred    // to in the graph.    nsCOMPtr<nsIRDFResource> resource;    const char* context;    rv = mDocumentURL->GetSpec(&context);    if (NS_FAILED(rv)) return rv;    rv = rdf_CreateAnonymousResource(context, getter_AddRefs(resource));    if (NS_FAILED(rv)) return rv;    nsXPIDLCString uri;    rv = resource->GetValue(getter_Copies(uri));    if (NS_FAILED(rv)) return rv;    rv = result->SetAttribute(kNameSpaceID_None, kIdAtom, (const char*) uri, PR_FALSE);    NS_ASSERTION(NS_SUCCEEDED(rv), "unable to set element's ID");    if (NS_FAILED(rv)) return rv;    // Set it's RDF:type in the graph s.t. the element's tag can be    // constructed from it.    nsCOMPtr<nsIRDFResource> type;    rv = MakeProperty(nameSpaceID, name, getter_AddRefs(type));    if (NS_FAILED(rv)) return rv;    rv = mDocumentDataSource->Assert(resource, kRDF_type, type, PR_TRUE);    NS_ASSERTION(NS_SUCCEEDED(rv), "unable to set element's tag info in graph");    if (NS_FAILED(rv)) return rv;    // Mark it as a XUL element    rv = mDocumentDataSource->Assert(resource, kRDF_instanceOf, kXUL_element, PR_TRUE);    NS_ASSERTION(rv == NS_OK, "unable to mark as XUL element");    if (NS_FAILED(rv)) return rv;    rv = rdf_MakeSeq(mDocumentDataSource, resource);    NS_ASSERTION(rv == NS_OK, "unable to mark as XUL element");    if (NS_FAILED(rv)) return rv;    // `this' will be its document    rv = result->SetDocument(this, PR_FALSE);    if (NS_FAILED(rv)) return rv;    // get the DOM interface    rv = result->QueryInterface(nsIDOMElement::GetIID(), (void**) aReturn);    NS_ASSERTION(NS_SUCCEEDED(rv), "not a DOM element");    if (NS_FAILED(rv)) return rv;    return NS_OK;}