if(format == null) {
out = new SPARQLResultsXMLWriter(os);
} else if(SparqlWritersHelper.parseSubType(format).equals("html")) {
out = new SPARQLResultsHTMLWriter(os, templatingService);
} else if(SparqlWritersHelper.parseSubType(format).equals("json")) {
out = new SPARQLResultsJSONWriter(os);
} else if(SparqlWritersHelper.parseSubType(format).equals("xml")) {
out = new SPARQLResultsXMLWriter(os);
} else if(SparqlWritersHelper.parseSubType(format).equals("csv")) {
out = new SPARQLResultsCSVWriter(os);
} else throw new InvalidArgumentException("could not produce format "+format);