cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Steve Krulewitz <>
Subject Internet Explorer, XHTML, and CForms
Date Tue, 23 Mar 2004 23:26:41 GMT
Tim Larson recently brought up the issue of the serialized 
representation of empty tags when using the XMLSerializer for serving 
XHTML [1].  This was sparked from a thread I had started on the users 
list about this issue.  I've done some considerable hair pulling over 
the past day, and I think I finally nailed it down.

The problem I ran into is this.  I want to serve my pages as XHTML, so 
I've been using the XMLSerializer with XHTML doctypes similar to the way 
it is set up in the stock root sitemap.  It is also well known that 
standards-compliant browsers like Mozilla will only render XHTML 
properly if sent with the "application/xhtml+xml" content type, where 
Internet Explorer will not accept this, and requires you to send it as 
"text/html".  This is easily solvable with some pipeline magic I posted 
about [2] -- I have another solution to this using a Tomcat Filter that 
I will post shorty.

Next I was trying to use a textarea on cforms.  No matter what I did, 
this would render incorrectly on Internet Explorer when the textarea is 
empty.  Because I'm using the XMLSerializer, an empty textarea gets 
rendered as:

<textarea name="foo" rows="10" cols="10" />

And this is why: no combination of doctypes, content types, filename 
extensions, etc, will make this work... because Internet Explorer just 
does not understand XHTML!  When Internet Explorer encounters an XHTML 
page, it still parses in "tag soup" mode and just discards XHTML-isms. 
Ian Hickson does a good job explaining this in his "Sending XHTML as 
text/html Considered Harmful." [3]  This strategy works pretty well, but 
fails miserably on the empty textarea element.

So as things stand right now, if someone wants to use a textarea in 
their forms and serve them as XHTML, they will run into problems on 
Internet Explorer.  I think this is a problem since it is *possible* to 
do this -- a textarea rendered with an explicit closing tag will render 
properly on Internet Explorer and will be valid XHTML.  However, I do 
not believe this is currently possible with Cocoon.

I believe the solution lies in extending the default XML stream writer 
that comes with Xalan (org.apache.xml.serializer.ToXMLStream).  A new 
output setting could be added that provides a list of element names that 
should never be minimized when they are empty.  This would allow the 
same XHTML pages that work on standards-compliant browsers to render 
properly in Internet Explorer.

It isn't clear to me if a new XML stream writer can be added to Xalan 
without modifying the Xalan source, but the actual coding does not look 
very hard.

What do you think?



View raw message