SPARQL描述查询不适用于java

时间:2018-01-12 21:16:17

标签: java sparql jena

我尝试使用sparql describe关键字。

PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>

DESCRIBE ?person WHERE {
  ?person rdf:type foaf:Person .
  FILTER EXISTS { ?person owl:sameAs ?sameAs }
}
LIMIT 100

我的describe查询正在处理http://dbpedia.org/sparql

我编写了执行查询的java程序,但我的代码无效。

ParameterizedSparqlString qs = new ParameterizedSparqlString( "" +
             "PREFIX foaf: <http://xmlns.com/foaf/0.1/> \r\n" + 
             "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\r\n" + 
             "PREFIX owl: <http://www.w3.org/2002/07/owl#>\r\n" + 
             "\r\n" + 
             "DESCRIBE ?person WHERE {\r\n" + 
             "  ?person rdf:type foaf:Person .\r\n" + 
             "  FILTER EXISTS { ?person owl:sameAs ?sameAs }\r\n" + 
             "}\r\n" + 
             "LIMIT 100");

     QueryExecution exec = QueryExecutionFactory.sparqlService( "http://dbpedia.org/sparql", qs.asQuery() );
     Model result = exec.execDescribe();

当我运行exec.execDescribe()时,我收到此错误:

  

org.apache.jena.riot.RiotException:[line:898,col:11]。   无法找到前缀名称或关键字: - (8211; 0x2013)。

你能帮我解释它为什么不工作吗?

0 个答案:

没有答案