PrintWriter tmp = new PrintWriter(new OutputStreamWriter(bout, "utf-8"));
try {
rsp.setContentType(xml ? "text/xml" : "text/html");
Tag tag = new Tag("result");
tag.addAttribute("start", new Date());
String template = doXML(tag, rq, rsp);
tag.addAttribute("end", new Date());
tmp.println("<?xml version='1.0'?>");
tmp.println("<?xml-stylesheet type='text/xsl' title='Compact' "
+ " href='" + template + ".xsl'?>");
tag.print(0, tmp);
tmp.flush();
if (!xml) {
// TODO use templates and cache these, this
// is horribly inefficient.