我正在尝试使用D2RQ运行查询。当我使用http://localhost:2020/sparql
中的PREFIX vocab: <http://localhost:2020/resource/vocab/>
SELECT ?personName WHERE {
?person vocab:people_Name ?personName .
}
浏览器运行查询时,一切正常,但使用Jena API时,它不会产生任何结果。查询是
ModelD2RQ m = new ModelD2RQ( "file:///C:/Users/sabse/Downloads/d2rq-0.8.1/d2rq-0.8.1/mapping-ontology.ttl");
String sparql =
"PREFIX vocab: <http://localhost:2020/resource/vocab/>" +
"SELECT ?personName WHERE {" +
" ?person vocab:people_Name ?personName . " +
"}";
Query q = QueryFactory.create(sparql);
ResultSet rs = QueryExecutionFactory.create(q, m).execSelect();
ResultSetFormatter.out(System.out, rs, q);
m.close();
这是构建查询并针对Model运行它的Java代码:
@prefix vocab: <vocab/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix d2rq: <http://www.wiwiss.fu-berlin.de/suhl/bizer/D2RQ/0.1#> .
@prefix jdbc: <http://d2rq.org/terms/jdbc/> .
数据以以下前缀声明开头:
{{1}}