Closed twistylittleworkshop closed 7 years ago
Okay, stand down. From a discussion in a resolved issue here, I must have not tried the exact combination of specifying default/named graphs. Smoothly running now, corrected code below:
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="/lib/rdfstore_min.js"></script>
<style>
</style>
<script type="text/javascript">
var global_store_ = null
var storeLoaded = function () {
global_store_.node("ex:john_smith", "ex:test", function(err, graph) {
console.log(graph)
})
global_store_.registeredGraphs(function(success, graphs){
var graph_uris = graphs.map(function(namedNode){
console.log(namedNode.nominalValue)
});
});
// simple query execution
global_store_.execute("SELECT * {?s ?p ?o }", ["http://www.example.org/people/test"],[],
function(err, results){
for (var i_ in results)
console.log(results[i_])
}
)
}
window.onload = function load (){
rdfstore.create(function(err, store) {
global_store_ = store
jsonld = {
"@context":
{
"rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
"xsd": "http://www.w3.org/2001/XMLSchema#",
"name": "http://xmlns.com/foaf/0.1/name",
"age": {"@id": "http://xmlns.com/foaf/0.1/age", "@type": "xsd:integer" },
"homepage": {"@id": "http://xmlns.com/foaf/0.1/homepage", "@type": "xsd:anyURI" },
"ex": "http://www.example.org/people/"
},
"@id": "ex:john_smith",
"name": "John Smith",
"age": "41",
"homepage": "http://example.org/home/"
}
store.setPrefix("ex", "http://www.example.org/people/")
store.load("application/ld+json", jsonld, "ex:test", function(err,results) {console.log(results);storeLoaded()})
});
}
</script>
</head>
<body>
</body>
</html>
Hi,
My RDF/SPARQL/rdfstore-js knowledge may be at fault here, but I'm trying to SPARQL-query a store created from JSON-LD, using fragments of code from the doc (src below) and the latest (0.9.17) .min.js version. The higher level node() func returns the triples, the registeredGraphs() func returns the graph URI, which I have tried as default and named graphs to the query call. At best, a zero-length array is returned from the SPARQL query. Same results if I embed the global callback into the store callbacks.
What am I not getting correct here?
Many thanks.
==================