I need to export/write the .ttl QuerySolution results to RDF/XML file.
I have tried the code below, but I am getting the following error with RDFDataMgr.write
:
The method write(OutputStream, Model, Lang) in the type RDFDataMgr is not applicable for the arguments (OutputStream, QuerySolution, Lang)
Query query = QueryFactory.create(queryString);
QueryExecution qexec= QueryExecutionFactory.create(query, model2);
try {
ResultSet resultat= qexec.execSelect();
while (resultat.hasNext()) {
QuerySolution sol=resultat.nextSolution();
String outfile = "/auto_home/rdftest/outfile.rdf";
OutputStream out = new FileOutputStream(outfile);
RDFDataMgr.write(out, sol, Lang.RDFXML);
}
} finally {
qexec.close();
}