It's DROP not DELETE in SPARQL Update.
DELETE is for triples, DROP is for whole graphs.
http://www.w3.org/TR/sparql11-update/#graphManagement
On 31/07/14 22:47, Arthur Keen wrote:
For executing CREATE or DELETE GRAPH in Fuseki
I tried to use them the same way as SPARQL INSERT/DELETE by posting to
../ds/update, but this did not work
Which Endpoint URL pattern I should use:
http://localhost:8080/ds/update,
http://localhost:8080/ds/graph
There are two things here:
1/ SPARQL Update -- CREATE and DROP -- use the "update" endpoint
2/ SPARQL Graph Store Protocol -- this is not SPARQL Update -- use a writeable
GSP endpoint.
GSP is normal HTTP usage on web resource GET/PUT/POST/DELETE/HEAD
http://www.w3.org/TR/sparql11-http-rdf-update/
what that document does is really explain how the REST(ish) use of HTTP applies
to graph store. It isn't defining anything new except the naming scheme for
graphs.
In GSP, the app (HTTP) PUT RDF syntax (Turtle, N-triples, JSON-LD) to create or
replace the contents of a graph and POST to create or add to a graph.
HTTP DELETE deletes a web resource as normal.
For Creating a graph do you use an http put or post request?
For deleting a graph do you use an http delete request
And the name of the variable to bind the query to. Using query, update, etc as
variable names, see commented out lines of code below
Thanks very much,
They don't take variables.
Just do e.g.
INSERT DATA { GRAPH :g { :s :p :o } }
and a graph is created for :g
INSERT
{ GRAPH ?g { :s :p :o } }
WHERE
{ ... ?g ... }
Whether CREATE is necessary in other situations depends on the storage
implementation. In Fuseki, with all the Jena provided storage
alternative, it is not needed.
It's possible other storage layers need graphs creating beforehand. I
don't know of any. In a quad store, it's fairly irrelevant distinction.
Any guidance would be much appreciated
Arthur
Hope that makes it clearer,
Andy
For context, here is the node.js code that I am using to call fuseki, with
commented out variations of httpreq that I have tried
//http://localhost:3000/graph/create?graphName=http://testGraph
app.get('/api/graph/create', function(req, res){
var update = "CREATE SILENT GRAPH <?:graphName>";
var graphName = req.param("graphName");
update = update.replaceAll("?:"+"graphName", graphName);
//httpreq.post(endpoint.getUpdateURL(), {parameters: {update:
update}}, function (geterr, getres){
//httpreq.post(endpoint.getGraphURL(), {parameters: {update:
update}}, function (geterr, getres){
httpreq.put(endpoint.getGraphURL(), {parameters: {query: update}},
function (geterr, getres){
if (geterr) return console.log(geterr);
res.send(endpoint.getGraphURL()+" "+ update+" "+ graphName);
});
});
//http://localhost:3000/graph/delete?graphName=http://testGraph
If you are using the default naming /delete and /create don't exist as services.
app.get('/graph/delete', function(req, res) {
var update = "DELETE SILENT GRAPH <?:graphName>";
var graphName = req.param("graphName");
update = update.replaceAll("?:" + "graphName", graphName);
//httpreq.post(endpoint.getUpdateURL(), {parameters: {update: update}},
function(geterr, getres) {
httpreq.delete(endpoint.getGraphURL(), {parameters: {graph: update}},
function(geterr, getres) {
if (geterr)
return console.log(geterr);
console.log(update);
res.send(endpoint.getGraphURL());
});
});
If you want security, you can either front Fuseki with httpd/nginx (that's
advisable anyway for any java web container), or wait for Fuseki2.
Andy