我需要将 .ttl QuerySolution 结果导出/写入 RDF/XML 文件。
我已经尝试了下面的代码,但我收到以下错误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();
}