Generating sitemap.xml in tapestry

229 views Asked by At

I am using tapestry (java framework) and I am trying to generate a sitemap.xml file. I need to create it dynamically and then return it as StreamResponse. I have the sitemapgen4j-1.0.1 library, but the library requires a path where the sitemap.xml should be written and that's something I don't want. Is there any way to use this library w/o writing the xml file? Also do I need to manually add every single link to the sitemap (using sitemapgen4j addUrl() method)?

1

There are 1 answers

0
Henning On

Looking at the source, no, there is not. You would need to fork sitemapgen4j and make it write to an OutputStream or Writer.

If you'd rather like to use the library as-is, you could create a temporary file (via File.createTempFile), pass that to sitemapgen4j, use it in your StreamResponse, and delete it after you're done reading.