From:  vaab <vaab@chez.com>
Date:  19 Apr 2005 23:08:03 Hong Kong Time
Newsgroup:  news.mozilla.org/netscape.public.mozilla.rdf
Subject:  

Re: sharing RDF datasource between iframes or through reload

NNTP-Posting-Host:  82.225.19.179

This is what I observed and used, sorry for not understanding all you 
might have explained ;), I understand that if my code is built on 
javascript bugs, this is not really clean ;)

In a basic script I have this line :

var ds = RDF.GetDataSource("rdf:composite-datasource");

which I've read about, and is supposed to load a composite-datasource. 
This datasource is the same through reload. This led to strange problem 
as I did a :

ds.AddDataSource(baseds);
ds.AddDataSource(memds);
...

which was stacking new references to databases in the composite 
datasource above precedent loaded in previous reload. As I use massively 
the reload button, my application tended to :
- slow down
- render strange results (deleted RDF assertions were always showing up...)

When I found the cause of my problems, I've written this code :
---

var enumerator = ds.GetDataSources();
enumerator = enumerator.
	QueryInterface(Components.interfaces.nsISimpleEnumerator);

while(enumerator.hasMoreElements()) {
   ds.RemoveDataSource(enumerator.getNext());
};
---

Which would empty my composite datasource each time the page reloads.

I posted this here to be clearer in my experiments. I'have some question 
: am I fighting against the odd caching artifact or not ? How can you 
call a brand new datasource each time ? is this correct :

var memds = Components
.classes["@mozilla.org/rdf/datasource;1?name=composite-datasource"]
.createInstance(Components.interfaces.nsIRDFDataSource);