I am looking for a way to add the results of this query into a 2D String List using Jena framework.
sparqlQueryString="
select distinct ?p ?o where
{
<http://dbpedia.org/resource/NVA_(film)> ?p ?o
}
";
in a way where the first row contains the properties and second their respective instances. The problem is that a property may have many instances.
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 : Server side solution: SPARQL 1.1 feature GROUP_CONCAT (see the W3C recommendation for examples). Client side solution: Java basics.