SPARQL:获取所有谓词及其各自的对象并将它们组织成一个列表

SPARQL: get all Predicates and their respective Objects and organize them into a List

我正在寻找一种使用 Jena 框架将此查询的结果添加到二维字符串列表中的方法。

 sparqlQueryString="
    select distinct ?p ?o where 
       {
         <http://dbpedia.org/resource/NVA_(film)> ?p ?o
       }
  ";

第一行包含属性,第二行包含它们各自的实例。问题是 属性 可能有很多实例。

    List<List<String>> results= new ArrayList<List<String>>();
    query = QueryFactory.create(sparqlQueryString);
    qexec = QueryExecutionFactory.sparqlService("http://dbpedia.org/sparql", query);
    s = qexec.execSelect();
    res = ResultSetFactory.copyResults(s);
     while(res.hasNext())
            {
                QuerySolution so = res.nextSolution();
                results.add(so.getResource("p").toString());
                // The part I am looking for to add instance

            }


    // the results expected
    results.get(0) = http://www.w3.org/1999/02/22-rdf-syntax-ns#type
    results.get(0).get(0) =     http://dbpedia.org/class/yago/2005Films
    results.get(0).get(1) =     http://www.w3.org/2002/07/owl#Thing
    results.get(0).get(2) =     http://dbpedia.org/ontology/Work

@AKSW:服务器端解决方案:SPARQL 1.1 功能 GROUP_CONCAT(有关示例,请参阅 W3C 推荐)。客户端解决方案:Java 基础。