【发布时间】:2013-03-27 16:03:25
【问题描述】:
我只是想在 DBpedia 上运行一个小查询,查询本身有效,请参阅 here,但我不明白为什么在使用 Jena 时它会返回,我得到了 null。
String service = "http://dbpedia.org/sparql";
String queryString = "";
queryString = "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> SELECT ?label" +
"WHERE {" +
"<http://dbpedia.org/resource/Quatre_Bornes> <http://dbpedia.org/ontology/country> ?y ."+
"?y rdfs:label ?label ."+
"FILTER (LANG(?label) = 'en')"+
"}";
Query query = QueryFactory.create(queryString);
QueryEngineHTTP qexec = QueryExecutionFactory.createServiceRequest(service, query);
ResultSet results = qexec.execSelect();
for ( ; results.hasNext() ; ) {
QuerySolution soln = results.nextSolution() ;
System.out.println(soln.getLiteral("label"));
}
有什么建议吗?
【问题讨论】:
-
您的回答很有道理,对其他人有用。 (我在其他问题中也出现了这个问题。)您应该接受您的答案,以便其他人知道它有效,并减少没有接受答案的问题的数量。
标签: java rdf sparql jena dbpedia