DBpedia Jena Query返回null

时间:2013-03-27 16:03:25

标签: java rdf sparql jena dbpedia

我只是试图在DBpedia上运行一个小查询,查询本身可以工作,看到它here,但我不知道为什么它在与Jena这样做时返回,我得到了null。 / p>

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"));
}

有什么建议吗?

1 个答案:

答案 0 :(得分:5)

这是如此令人尴尬,查询中存在空间问题:

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')"+
            "}";