rdfstore-js
rdfstore-js copied to clipboard
LOAD query into default graph
Hi,
version: 0.9.6 with PR #99 applied (using node.js)
I currently try to load an external file via LOAD query; although the query seems to succeed, the store seems to be empty:
rdfstore.create(function(err, store) {
if (err) { /* error handling */ }
// - load remote RDF document
// NOTE: timbl-foaf.ttl is a Turtle version of http://dig.csail.mit.edu/2008/webdav/timbl/foaf.rdf
store.execute('LOAD <https://kindl.io/sw-examples/timbl-foaf.ttl>', function(success, num_triples) {
if (!success) { /* error handling */ }
/* success = true */
/* num_triples = 211 */
store.graph(function(err, graph) { console.log(graph); /* empty */});
});
});
Did I miss a thing?
store.graph('https://kindl.io/sw-examples/timbl-foaf.ttl', function(err, graph) { /*...*/ });
returns the graph with all loaded triples, so I missed a thing ;-)
Anyhow, according to the SPARQL 1.1 Update spec a SPARQL LOAD query without an INTO clause should populate the default graph (cf. spec) -- it seems that this is not the case here..
var fileString = app.fs.readFileSync(app.dir + '/rdf/imd.nt').toString();
rdfstore.create(function(err, store) {
store.load("text/n3", fileString, "<http://example.org/imd>", function(err, loaded) {
if (err) console.log(err);
console.log("triples loaded: ", loaded); /** triples loaded: 194892 **/
store.registeredGraphs(function(err, res){
console.log(res);
/** [ { [String: '<http://example.org/imd>']
interfaceName: 'NamedNode',
attributes: [ 'interfaceName', 'nominalValue' ],
nominalValue: '<http://example.org/imd>' } ] **/
store.graph("http://example.org/imd", function(err, res){
if (err) console.log("ERR: " + err);
console.log(res);
/** { triples: [], duplicates: {}, actions: [], length: 0 } **/
});
});
});
});
Here I tried to load rdf from file, 194892 triples loaded and a namedGraph is also created, but when I tried to retrieve the graph to see its content, the graph has no triples. I also tried to run SELECT query, but it still results in an empty array []. Can anyone help me with this? Thanks a lot!
Please I really need to learn about this asap @antoniogarrote @ckristo ^^