<snip/>
So, in my opinion, the "best" way to tackle the charset-encoding problem is to have the org.apache.cocoon.serialization.AbstractTextSerializer to receive an OutputStream from its implementation of the SitemapOutputComponent interface, but to expose to its solid implementations another couple of methods, instead of "getOutputStream":
- String getCharsetEncoding() [or getCharacterEncoding]:
Returns the default character encoding configured for the specified
AbstractTextSerializer (or the default one for the sitemap if none
was specified).
This can be usefult (for example) in the HtmlSerializer so that a new
<meta http-equiv="Content-Type" content="text/html; charset=???"/>
tag can be added automagically to the output, or to the "XMLSerializer"
so that the "<?xml version="1.0" encoding="???"?>" initial processing
instruction can be constructed appropriately.
It (<?xml?> instruction) done via format.put(OutputKeys.ENCODING,encoding.getValue()) in abstract serializer itself.
- Writer getWriter():
Returns a java.io.Writer encoding character data to the response output stream according to whatever is returned by getCharsetEncoding
Those two should be controlled from the sitemap by (as you, Stefano, said):
Sounds good.
2) also, i want a way to overwrite the sitemap-wide behavior of every single serializers, locally, such as
<map:serialize encoding="UTF-8"/>
The only "nitpick" I have is that since "encoding" means a lot of things, this should be called "charset" (which is way more specific)...
This can be easily picked up by the AbstractTextSerializer.configure() method and returned by the two methods added above...
I can work on a patch if you guys want... It's pretty trivial indeed...
Not that trivial. Configure works only globally. Right now serializers do not have local configuration - because they don't implement SitemapModelComponent and its setup() method.
Sitemap implementation has to be changed to test serializers for SitemapModelComponent interface, and caching pipeline should test for it too (IIRC, old implementation did that, not sure about new one).
Vadim
Pier