}
pw.println("\n ]\n}");
response.flushBuffer();
} else if ("xml".equals(format)) {
URLStrategy urlstrat = roller.getUrlStrategy();
response.setContentType("application/tagdata+xml; charset=utf-8");
PrintWriter pw = response.getWriter();
pw.println("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
pw.println("<categories fixed=\"no\" ");
pw.println(" xmlns=\"http://www.w3.org/2007/app\"");
pw.println(" xmlns:atom=\"http://www.w3.org/2005/Atom\"");
pw.println(" xmlns:tagdata=\"http://roller.apache.org/ns/tagdata\">");
int count = 0;
for (Iterator it = tags.iterator(); it.hasNext();) {
TagStat stat = (TagStat) it.next();
String term = stat.getName();
String viewURI = urlstrat.getWeblogCollectionURL(weblog,
null, // locale
null, // category
null, // date string
Collections.singletonList(stat.getName()),
0, // page
true); // absolute
int frequency = stat.getCount();
pw.print("<atom:category term=\"" + term + "\" tagdata:frequency=\"" + frequency + "\" ");
pw.println("tagdata:href=\"" + viewURI + "\" />");
if (count++ > MAX) break;
}
if (tags.size() > MAX) {
// get next URI, if site-wide then don't specify weblog
String nextURI = urlstrat.getWeblogTagsJsonURL(weblog, true, page + 1);
pw.println("<atom:link rel=\"next\" href=\"" + nextURI + "\" />");
}
if (page > 0) {
// get prev URI, if site-wide then don't specify weblog
String prevURI = urlstrat.getWeblogTagsJsonURL(weblog, true, page - 1);
pw.println("<atom:link rel=\"previous\" href=\"" + prevURI + "\" />");
}
pw.println("</categories>");
response.flushBuffer();
} else {