Looking at the source, my best guess is that I need to use nsIRDFContentSink
to parse it into something a datasource will understand.
The problem I have with nsIRDFContentSink is that it only exists as a C++
headerfile. There's no IDL, and without that I don't think I can make it
work with Javascript (I tried the ClassID and the IID to try and create an
instance, without success).
Is this the right route to take, or should I be creating a new datasource
for each graph? If so, is there a clean way to merge the data with the main
datasource (other than listing all the statements out)?
Will.
chris
http://bugzilla.mozilla.org/show_bug.cgi?id=35816
I broke out the parsing and serialization stuff from nsRDFXMLDataSource,
so these objects can now be instantiated on their own; e.g., to parse a
string:
var ios = Components.classes["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService);
var ds =
Components.classes["@mozilla.org/rdf/datasource;1?name=in-memory-datasource"].
createInstance(Componetns.interfaces.nsIRDFDataSource);
var p = Components.classes["@mozilla.org/rdf/xml-parser;1"]
.createInstance(Components.interfaces.nsIRDFXMLParser);
var uri = ios.newURI("http://foo.com/blah.rdf", null);
p.parseString(ds, uri, "<RDF:RDF xmlns:RDF='...'>...</RDF:RDF>");
Or, alternatively, to serialize an arbitrary datasource:
var ds = /* get this somehow */;
var s = Components.classes["@mozilla.org/rdf/xml-serializer;1"]
.createInstance(Components.interfaces.nsIRDFXMLSerializer);
s.init(ds);
out = { /* minimal impl of nsIOutputStream, Serialize()
will only call |write()| */
function: write(buf, count) { dump(buf); return count; }
};
s.QueryInterface(Components.interfaces.nsIRDFXMLSource)
.Serialize(out);
Also, the RDF/XML that we serialize should be a lot more legible to
humans once I check this in.
chris
Sweet, thank you!
Will.