nsAutoString	allowNegativeAssertionsStr; rv = aElement->GetAttribute(kNameSpaceID_None, kAllowNegativeAssertionsAtom, allowNegativeAssertionsStr); if ((rv == NS_CONTENT_ATTR_HAS_VALUE) && (allowNegativeAssertionsStr.Equals("false"))) { db->SetAllowNegativeAssertions(PR_FALSE); }  nsAutoString	coalesceDuplicateArcsStr; rv = aElement->GetAttribute(kNameSpaceID_None, kCoalesceDuplicateArcsAtom, coalesceDuplicateArcsStr); if ((rv == NS_CONTENT_ATTR_HAS_VALUE) && (coalesceDuplicateArcsStr.Equals("false"))) { db->SetCoalesceDuplicateArcs(PR_FALSE); }
RDFXULBuilderImpl::CreateTemplateBuilder(nsIContent* aElement,                                         const nsString& aDataSources,                                         nsIRDFContentModelBuilder** aResult){    nsresult rv;    // construct a new builder    nsCOMPtr<nsIRDFContentModelBuilder> builder;    rv = nsComponentManager::CreateInstance(kXULTemplateBuilderCID,                                            nsnull,                                            kIRDFContentModelBuilderIID,                                            (void**) getter_AddRefs(builder));    NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create tree content model builder");    if (NS_FAILED(rv)) return rv;    if (NS_FAILED(rv = builder->SetRootContent(aElement))) {        NS_ERROR("unable to set builder's root content element");        return rv;    }    // create a database for the builder    nsCOMPtr<nsIRDFCompositeDataSource> db;    rv = nsComponentManager::CreateInstance(kRDFCompositeDataSourceCID,                                            nsnull,                                            kIRDFCompositeDataSourceIID,                                            getter_AddRefs(db));    if (NS_FAILED(rv)) {        NS_ERROR("unable to construct new composite data source");        return rv;    }    // Add the local store as the first data source in the db. Note    // that we _might_ not be able to get a local store if we haven't    // got a profile to read from yet.    nsCOMPtr<nsIRDFDataSource> localstore;    rv = gRDFService->GetDataSource("rdf:local-store", getter_AddRefs(localstore));    if (NS_SUCCEEDED(rv)) {        rv = db->AddDataSource(localstore);        NS_ASSERTION(NS_SUCCEEDED(rv), "unable to add local store to db");        if (NS_FAILED(rv)) return rv;    }    // Parse datasources: they are assumed to be a whitespace    // separated list of URIs; e.g.,    //    //     rdf:bookmarks rdf:history http://foo.bar.com/blah.cgi?baz=9    //    PRInt32 first = 0;    nsCOMPtr<nsIDocument> document = do_QueryInterface(mDocument);    if (! document)        return NS_ERROR_UNEXPECTED;    nsCOMPtr<nsIURI> docURL = dont_AddRef( document->GetDocumentURL() );    if (! docURL)        return NS_ERROR_UNEXPECTED;    while(1) {        while (first < aDataSources.Length() && nsString::IsSpace(aDataSources.CharAt(first)))            ++first;        if (first >= aDataSources.Length())            break;        PRInt32 last = first;        while (last < aDataSources.Length() && !nsString::IsSpace(aDataSources.CharAt(last)))            ++last;        nsAutoString uri;        aDataSources.Mid(uri, first, last - first);        first = last + 1;        rv = rdf_MakeAbsoluteURI(docURL, uri);        if (NS_FAILED(rv)) return rv;        // A special 'dummy' datasource        if (uri.Equals("rdf:null"))            continue;        nsCOMPtr<nsIRDFDataSource> ds;        // Some monkey business to convert the nsAutoString to a        // C-string safely. Sure'd be nice to have this be automagic.        {            char buf[256], *p = buf;            if (uri.Length() >= PRInt32(sizeof buf))                p = (char *)nsAllocator::Alloc(uri.Length() + 1);            uri.ToCString(p, uri.Length() + 1);            rv = gRDFService->GetDataSource(p, getter_AddRefs(ds));            if (p != buf)                nsCRT::free(p);        }        if (NS_FAILED(rv)) {            // This is only a warning because the data source may not            // be accessable for any number of reasons, including            // security, a bad URL, etc.#ifdef DEBUG            nsCAutoString msg;            msg += "unable to load datasource '";            msg += nsCAutoString(uri);            msg += '\'';            NS_WARNING((const char*) msg);#endif            continue;        }        if (NS_FAILED(rv = db->AddDataSource(ds))) {            NS_ERROR("unable to add datasource to composite data source");            return rv;        }    }    // add it to the set of builders in use by the document    rv = mDocument->AddContentModelBuilder(builder);    NS_ASSERTION(NS_SUCCEEDED(rv), "unable to add builder to the document");    if (NS_FAILED(rv)) return rv;    rv = builder->SetDataBase(db);    NS_ASSERTION(NS_SUCCEEDED(rv), "unable to set builder's database");    if (NS_FAILED(rv)) return rv;    *aResult = builder;    NS_ADDREF(*aResult);    return NS_OK;}