Re: How to open "file://"-RDF, change it and flush it to somewhere else?

Axel Hecht <[email protected]>
Newsgroups gmane.comp.mozilla.devel.rdf
Organization Another Netscape Collabra Server User
Message-ID <[email protected]>
Manuel Reimer wrote:
> Hello,
> 
> what do I have to do to open a "file://"-RDF and save it, after 
> changing, to somewhere else *without* changing the initially opened file?
> 
> Currently I use this code:
> 
> | var rdfService = Components.classes["@mozilla.org/rdf/rdf-service;1"].
> |                    getService(Components.interfaces.nsIRDFService);
> | | var ds=rdfService.GetDataSourceBlocking("file:///tmp/inputtest.rdf");
> | | var subject = rdfService.GetResource("http://www.example.com/test");
> | var predicate = |      
> rdfService.GetResource("http://www.example.com/rdf#name");
> | var name = rdfService.GetLiteral("This is a test");
> | | ds.Assert(subject, predicate, name, true);
> | | ds.QueryInterface(Components.interfaces.nsIRDFRemoteDataSource);
> | ds.FlushTo("file:///tmp/outtest.rdf");
> | rdfService.UnregisterDataSource(ds);
> 
> This saves my output file, but always changes the input file, too.

Yes, that's what it's supposed to do.

The only way that I see is using a non-file datasource for your 
modifications. There are several ways for that, faking a protocol or 
using a in mem ds and doing parsing and serializing by hand.

Maybe others, too.

Axel
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.