db->SetAllowNegativeAssertions(PR_FALSE); db->SetCoalesceDuplicateArcs(PR_FALSE);
XULDocumentImpl::EndLoad(){    // Set up the document's composite datasource, which will include    // the main document datasource and the local store. Only do this    // if we are a bona-fide top-level XUL document; (mParentContentSink !=    // nsnull) implies we are a XUL overlay.    if (mParentContentSink == nsnull) {        //NS_PRECONDITION(mRootResource != nsnull, "no root resource");        if (! mRootResource)            return NS_ERROR_UNEXPECTED;        nsresult rv;        nsCOMPtr<nsIRDFCompositeDataSource> db;        rv = nsComponentManager::CreateInstance(kRDFCompositeDataSourceCID,                                                nsnull,                                                kIRDFCompositeDataSourceIID,                                                (void**) getter_AddRefs(db));        NS_ASSERTION(NS_SUCCEEDED(rv), "couldn't create composite datasource");        if (NS_FAILED(rv)) return rv;        // Create a XUL content model builder        rv = nsComponentManager::CreateInstance(kRDFXULBuilderCID,                                                nsnull,                                                kIRDFContentModelBuilderIID,                                                getter_AddRefs(mXULBuilder));        NS_ASSERTION(NS_SUCCEEDED(rv), "couldn't create XUL builder");        if (NS_FAILED(rv)) return rv;        rv = mXULBuilder->SetDataBase(db);        NS_ASSERTION(NS_SUCCEEDED(rv), "couldn't set builder's db");        if (NS_FAILED(rv)) return rv;        mBuilders = nsnull; // release content model builders.        rv = AddContentModelBuilder(mXULBuilder);        NS_ASSERTION(NS_SUCCEEDED(rv), "could't add XUL builder");        if (NS_FAILED(rv)) return rv;        // Add the local store to the composite datasource. It's first        // so that any local annotations will over-ride default values        // from the document. Note that we may not be able to get a        // local store if we don't yet have a profile.        rv = gRDFService->GetDataSource("rdf:local-store", getter_AddRefs(mLocalStore));        if (NS_SUCCEEDED(rv)) {            rv = db->AddDataSource(mLocalStore);            NS_ASSERTION(NS_SUCCEEDED(rv), "couldn't add local data source to db");            if (NS_FAILED(rv)) return rv;        }        // Add the main document datasource to the content model builder        rv = db->AddDataSource(mDocumentDataSource);        NS_ASSERTION(NS_SUCCEEDED(rv), "unable to add XUL datasource to db");        if (NS_FAILED(rv)) return rv;        // Now create the root content for the document.        rv = mXULBuilder->CreateRootContent(mRootResource);        if (NS_FAILED(rv)) return rv;        NS_POSTCONDITION(mRootContent != nsnull, "unable to create root content");        if (! mRootContent)            return NS_ERROR_UNEXPECTED;        // Do any initial hookup that needs to happen.        rv = ResolveForwardObserverDecls();        if (NS_FAILED(rv)) return rv;        // XXX Because we are now doing this, maybe we can remove all        // the code from the RDFXULBuilderImpl that adds and removes        // elements from the element map?        rv = AddSubtreeToDocument(mRootContent);        if (NS_FAILED(rv)) return rv;    }    StartLayout();    for (PRInt32 i = 0; i < mObservers.Count(); i++) {        nsIDocumentObserver* observer = (nsIDocumentObserver*) mObservers[i];        observer->EndLoad(this);        if (observer != (nsIDocumentObserver*)mObservers.ElementAt(i)) {          i--;        }    }    return NS_OK;}