public void render(
     WebSitemapUrl url, OutputStreamWriter out, W3CDateFormat dateFormat, String additionalData)
     throws IOException {
   out.write("  <url>\n");
   out.write("    <loc>");
   out.write(url.getUrl().toString());
   out.write("</loc>\n");
   if (url.getLastMod() != null) {
     out.write("    <lastmod>");
     out.write(dateFormat.format(url.getLastMod()));
     out.write("</lastmod>\n");
   }
   if (url.getChangeFreq() != null) {
     out.write("    <changefreq>");
     out.write(url.getChangeFreq().toString());
     out.write("</changefreq>\n");
   }
   if (url.getPriority() != null) {
     out.write("    <priority>");
     out.write(url.getPriority().toString());
     out.write("</priority>\n");
   }
   if (additionalData != null) out.write(additionalData);
   out.write("  </url>\n");
 }
  private void writeSiteMap(OutputStreamWriter out) throws IOException {
    out.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
    out.write("<sitemapindex xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n");
    for (SitemapIndexUrl url : urls) {
      out.write("  <sitemap>\n");
      out.write("    <loc>");
      out.write(url.url.toString());
      out.write("</loc>\n");
      Date lastMod = url.lastMod;

      if (lastMod == null) lastMod = defaultLastMod;

      if (lastMod != null) {
        out.write("    <lastmod>");
        out.write(dateFormat.format(lastMod));
        out.write("</lastmod>\n");
      }
      out.write("  </sitemap>\n");
    }
    out.write("</sitemapindex>");
    out.close();
  }