I am trying to output an RDF/XML file directly from an SPARQL query from an Oracle database. The query is working fine as I've verified the results in the ResultSet object.
However, I'm not sure how to proceed from there. I think I want to create a Statement for each QuerySolution and then add it to the Model. However I can't figure out a way to do it, because I can't find a way to get the predicate value.
Any help would be appreciated, as well as hints whether I am going down the right path.
QueryExecution qe = QueryExecutionFactory.create(query, oracleSemModel) ;
ResultSet results = qe.execSelect();
Model model = ModelFactory.createDefaultModel();
while (results.hasNext())
{
QuerySolution result = results.next();
Resource subject = result.getResource("s"); // get the subject
Property predicate = result.getProperty("p"); // <-- THIS FUNCTION DOESN'T EXIST
RDFNode object = result.get("o"); // get the object
Statement stmt = ResourceFactory.createStatement(subject, predicate, object);
model.add(stmt);
}
model.write(System.out, "RDF/XML-ABBREV");