Jena SPARQL クエリの結果から .txt または .xls ファイル出力を作成する方法を知りたいです。誰でも助けることができますか?
ここにコードの一部
InputStream in = new FileInputStream(new File("./src/myfile.owl"));
Model model = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM_MICRO_RULE_INF, null);
model.read(in, null);
in.close();
String queryString =
"prefix : <http://www.semanticweb.org/thato/ontologies/2012/10/9/thesis_ontology_1try#> " +
"prefix rdfs: <" + RDFS.getURI() + "> " +
"prefix owl: <" + OWL.getURI() + "> " +
"prefix rdf: <" + RDF.getURI() + "> " +
"select ?Model " +
"where {" +
"{?Model rdf:type :ApplicationModel. " +
"?Model :hasDomain ?domain. " +
"?domain :domainCode ?domaincode. " +
"FILTER (?domaincode =" + "'"+ domainElement.getAttribute(attrDomain) + "'"+ ")" +
"?Model :hasPhase ?phase." +
"?phase :name ?phasecode. " +
"FILTER (?phasecode = "+ "'"+ phaseElement.getAttribute(attrPhase)+"'"+")" +
"?Model :hasLevelOfDetail ?lod." +
"?lod :name ?lodcode." +
"FILTER (?lodcode = "+ lodElement.getAttribute(attrLOD) +")" +
"}"
;
Query query = QueryFactory.create(queryString);
QueryExecution qe = QueryExecutionFactory.create(query, model);
ResultSet results = qe.execSelect();
ResultSetFormatter.out(System.out, results, query);
qe.close();
}
}