//build outputwriter
final TupleQueryResultWriter out;
if(format == null) {
out = QueryResultIO.createWriter(TupleQueryResultFormat.SPARQL, os);
} else if(SparqlWritersHelper.parseSubType(format).equals("html")) {
out = new SPARQLResultsHTMLWriter(os, templatingService);
} else if(SparqlWritersHelper.parseSubType(format).equals("json")) {
out = QueryResultIO.createWriter(TupleQueryResultFormat.JSON, os);
} else if(SparqlWritersHelper.parseSubType(format).equals("xml")) {
out = QueryResultIO.createWriter(TupleQueryResultFormat.SPARQL, os);
} else if(SparqlWritersHelper.parseSubType(format).equals("csv")) {