hi all! i need to manipulate with remote rdf data manually. the aim is to show user some data in a dialog (e.g., set of textboxes) and then retrieve via js all data modifications being made.
hence i looked for nsIRDFDataSource with the following result: to access the information in a datasource one should use functions like GetTarget(), GetSource() etc (?)
but i've not found any (even stale) legible example of using of such functionality! i've written some snippets but they're barely working.
for example, such code =========================================================== netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); var rdf = Components.classes["@mozilla.org/rdf/rdf-service;1"].getService (Components.interfaces.nsIRDFService);
var ds = rdf.GetDataSourceBlocking("chrome://somepath/somefile.rdf"); ds = ds.QueryInterface(Components.interfaces.nsIRDFDataSource);
var p = rdf.GetResource('urn:ftdlg:data'); var t = rdf.GetResource('rdf:http://www.foo.by/rdf#car-model'); var explSrc = ds.GetSource(p, t, true );
var counter = 0;
var mysource = ds.GetAllResources(); while( mysource.hasMoreElements() ){
var mydata = mysource.getNext();
counter++;
}
alert("explicit source=" + explSrc + "\ntotal: " + counter);
===========================================================
in [p] and [t] i see 'urn:ftdlg:data' and
'rdf:http://www.foo.by/rdf#car-model' respectively.
perhaps i do something extremely stupid...
the [explSrc] is NULL (?) but [counter] correctly shows the number of entries in rdf. is there any technique to retrieve a real data from [mydata] variable?
mydata needs to be QueryInterfaced to nsIRDFResource. Then you can call mydata.Value.
i can show the rdf file if it helps...
in short, i need to get the data from rdf file via xpcom. any advices or (and?) code examples would be groundbreaking. thanx.
You probably mean to use 'http://www.foo.by/rdf#car-model' without the 'rdf:'. Also, do you mean getTarget instead of getSource? Without seeing the RDF data, I'm not sure.
/ Neil
_______________________________________________ Mozilla-xpcom mailing list [EMAIL PROTECTED] http://mail.mozilla.org/listinfo/mozilla-xpcom
