我试着删除所有三元,我有这些funcions,SPARQL删除statment耶拿OWL
类变量
public static String defaultNameSpace = "http://www.semanticweb.org/admin/ontologies/2016/3/Inventory#";
public Model Inventario = null;
public Model schema = null;
public String DatabaseFile = "PR2INVENTARIORDFXML.owl";
public OutputStream output;
public ResultSet runQuery(String queryRequest, Model model)
{
StringBuffer queryStr = new StringBuffer();
ResultSet response = null;
// Establish Prefixes
//Set default Name space first
queryStr.append("PREFIX base: <" + defaultNameSpace + "> ");
queryStr.append("PREFIX rdfs: <" + "http://www.w3.org/2000/01/rdf-schema#" + "> ");
queryStr.append("PREFIX rdf: <" + "http://www.w3.org/1999/02/22-rdf-syntax-ns#" + "> ");
queryStr.append("PREFIX owl: <http://www.w3.org/2002/07/owl#>");
//Now add query
queryStr.append(queryRequest);
Query query = QueryFactory.create(queryStr.toString());
QueryExecution qexec = QueryExecutionFactory.create(query, model);
try
{
response = qexec.execSelect();
}
finally { }
return response;
}
我对每个查询的功能,这里有一个例子
public ResultSet AllRecords(Model model)
{
return runQuery("select ?s ?p ?o where{?s ?p ?o."
+ "} " , model);
}
当我尝试运行这些查询时
public ResultSet BorrarPC(Model model)
{
return runQuery("DELETE {base:PC1 ?p ?o} " +
"WHERE {base:PC1 ?p ?o}" +
"" , model);
}
public ResultSet eraseAllTriples(Model model)
{
return runQuery("DELETE {?s ?p ?o} " +
"WHERE {?s ?p ?o}" +
"" , model);
}
它给了我这些错误
run:
异常线程“main” com.hp.hpl.jena.query.QueryParseException:遇到“‘删除’”删除‘’第1行,列233 当时期待之一: “前缀” ...... “中选择” ...... “形容” ...... “构建” ...... “问” ......
at com.hp.hpl.jena.sparql.lang.ParserSPARQL11.perform(ParserSPARQL11.java:87)
at com.hp.hpl.jena.sparql.lang.ParserSPARQL11.parse(ParserSPARQL11.java:40)
at com.hp.hpl.jena.query.QueryFactory.parse(QueryFactory.java:132)
at com.hp.hpl.jena.query.QueryFactory.create(QueryFactory.java:69)
at com.hp.hpl.jena.query.QueryFactory.create(QueryFactory.java:40)
at com.hp.hpl.jena.query.QueryFactory.create(QueryFactory.java:28)
at explorerowlexample.FinalProject.runQuery(FinalProject.java:146)
at explorerowlexample.FinalProject.BorrarPC(FinalProject.java:90)
at explorerowlexample.FinalProject.main(FinalProject.java:56)
Java结果:1 BUILD SUCCESSFUL(总时间:5秒)
任何人都可以帮助我如何创建删除语句?
谢谢
'com.hp.hpl.jena'显示您正在使用旧版本。现在,Jena3,所有的软件包都是'org.apache.jena'。 – AndyS