cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From BURGHARD Éric <>
Subject Re: Suggestion for XHTMLSerializer
Date Fri, 05 Aug 2005 11:49:53 GMT
Thorsten Scherler wrote:

> On Tue, 2005-08-02 at 11:25 +0200, Antonio Fiol Bonnín wrote:
>> Hello,
>> I am finding a problem with empty elements when serving content with
>> the text/html content type on Firefox.
>> For example, collapsed empty div elements cause havoc in firefox. A
>> possible workaround would be implementing the compatibility guidelines
>> indicated in the W3C recommendations.
>> In particular, I would add the same check already present for style,
>> script and textarea for any element whose end tag is required in HTML
>> 4.01.

I found a simple solution to this problem.

In fact the XMLSerializer didn't take the 'method' parameter into account.
At least in saxon8 (never test with other xslt processor, but it should
work too), if you put <xsl:output method="xhtml"/> all tags like div,
script, or inputarea remains unclosed.

I think this is a bug with XMLSerializer which enforce the method to be
'xml'. The folowing simple class let you choose the serialization method.

public class XMLSerializer2 extends AbstractTextSerializer {

     * Set the configurations for this serializer.
    public void configure(Configuration conf)
    throws ConfigurationException {
        super.configure( conf );

     * Set the {@link OutputStream} where the requested resource should
     * be serialized.
    public void setOutputStream(OutputStream out) throws IOException {
        try {
            TransformerHandler handler = this.getTransformerHandler();
            handler.setResult(new StreamResult(this.output));
        } catch (Exception e) {
            final String message = "Cannot set XMLSerializer outputstream"; 
            throw new CascadingIOException(message, e);


Now just configure this serializer in sitemap.xmap like you do with regular

<map:serializer logger="sitemap.serializer.xhtml" mime-type="text/html"
name="xhtml" pool-grow="2" pool-max="64" pool-min="2"
                <doctype-public>-//W3C//DTD XHTML 1.0

                <!-- for i6 compat mode-->

I wrote a much more powerfull solution: the XSLSerializer, which let you
control the serialization through an xsl stylesheet (an so use the
xsl:output tag as well as some template rules to make final cleanup like
namespace deletion or href contextualization). I need to do some cleanup,
and i will submit a patch.


View raw message