sparql - Delete RDF tuple using dotNetRDF -
this question has answer here:
i'd delete rdf tuple using dotnetrdf. here rdf file:
<rdf:rdf xml:base="http://www.example.org/destdetails#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:xsd="http://www.w3.org/2001/xmlschema#" xmlns:ns0="http://www.example.org/destdetails#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> <rdf:description rdf:about="&ns0;0165a659-54ea-4e80-bee7-9d3951d47ae3"> <ns0:id>0165a659-54ea-4e80-bee7-9d3951d47ae3</ns0:id> <ns0:destination rdf:resource="&ns0;veles" /> <ns0:distrname>test test</ns0:distrname> <ns0:hastimestart>17:00</ns0:hastimestart> <ns0:hastimestop>17:55</ns0:hastimestop> <ns0:moneyonedir>130 den.</ns0:moneyonedir> <ns0:moneytwodir>---</ns0:moneytwodir> </rdf:description> </rdf:rdf>
here code using:
triplestore magacintorki = new triplestore(); //kreiranje na graf graph rdf = new graph(); // create dataset , use named graph default graph fileloader.load(rdf, rdfdatoteka, new rdfxmlparser()); rdf.baseuri = new uri("http://www.example.org/destdetails"); // remove name graph // if graph has no name added default graph magacintorki.add(rdf); sparqlupdateparser parser = new sparqlupdateparser(); sparqlparameterizedstring cmdstring = new sparqlparameterizedstring(); cmdstring.commandtext = @"prefix ns0: <http://www.example.org/destdetails#>" + " prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>" + " delete " + " {" + " graph @graph { ?dest ?p ?o" + " ?dest ns0:nodeid @destid} }"; cmdstring.seturi("graph",rdf.baseuri); cmdstring.setliteral("destid",destid); sparqlupdatecommandset cmds = parser.parsefromstring(cmdstring); leviathanupdateprocessor processor = new leviathanupdateprocessor(magacintorki); processor.processcommandset(cmds); rdf.savetofile(rdfdatoteka);
however nothing happening rdf file.
this code works fine me, because not asked delete triples using sparql
graph rdf = new graph(); // create dataset , use named graph default graph fileloader.load(rdf, rdfdatoteka, new rdfxmlparser()); rdf.baseuri = new uri("http://www.example.org/destdetails"); inode n = rdf.geturinode(new uri("http://www.example.org/destdetails#" + destid)); if (n != null) { rdf.retract(rdf.gettripleswithsubject(n)); } rdf.savetofile(rdfdatoteka);
where destid
subject of triples.
your query not match data why delete
has no effect.
in data have ns0:id
in delete
try match against ns0:nodeid
- therefore no data matched , nothing deleted.
Comments
Post a Comment