You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Steve Krulewitz <sh...@mm.st> on 2004/03/24 00:26:41 UTC

Internet Explorer, XHTML, and CForms

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?

cheers,
-steve

[1] http://marc.theaimsgroup.com/?m=107999114518402
[2] http://marc.theaimsgroup.com/?m=108001750400120
[3] http://www.hixie.ch/advocacy/xhtml

Re: Internet Explorer, XHTML, and CForms

Posted by Antonio Gallardo <ag...@agssa.net>.
Steve Krulewitz dijo:
> What do you think?

<joke>
Looks to me as a ugly hack. Why we need to hack to patch a buggie browser
that not meet the specifications? I think this is a not a good idea?
Another solution is tell your users the browser they use is buggie and ask
them to download a better browser :-D
</joke>

Seriously, first of all, thanks for digging in this problem and point out
the problem.

It will be very hard if not imposible adding a special hack for a bug in a
current release of a browser. AFAIK a <map:selector> allow you to know
what kind of browser sent the request and based on this info you can use a
customized serializer to workaround the problem.

Best Regards,

Antonio Gallardo

Re: Internet Explorer, XHTML, and CForms

Posted by Steve Krulewitz <sh...@mm.st>.
Pier Fumagalli wrote:

> I hear you, the serializers for plain XHTML are quite nasty... I  
> noticed some odd behavior also on the <script> and <style> tags (not  
> all browsers like when they look like <tag />).
> 
> Well, anyhow, I fixed it now, if you want to try it out, check if this  
> serializer works for you:
> 
> http://cvs.apache.org/viewcvs.cgi/cocoon-2.1/src/blocks/scratchpad/ 
> garbage/source/java/org/apache/garbage/serializer/XHTMLSerializer.java? 
> rev=1.3&view=auto
> 
> It's in the scratchpad.

*THANK YOU*

This will help out immensely. I have it checked out and will try it out 
tomorrow.

cheers,
-steve

Re: Internet Explorer, XHTML, and CForms

Posted by Pier Fumagalli <pi...@betaversion.org>.
On 23 Mar 2004, at 23:26, Steve Krulewitz wrote:

> 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.

I thought I fixed it into the XHTML serializers I put in the scratchpad  
with the old Garbage implmentation, but looking at the code right now,  
err, no I didn't...

I hear you, the serializers for plain XHTML are quite nasty... I  
noticed some odd behavior also on the <script> and <style> tags (not  
all browsers like when they look like <tag />).

Well, anyhow, I fixed it now, if you want to try it out, check if this  
serializer works for you:

http://cvs.apache.org/viewcvs.cgi/cocoon-2.1/src/blocks/scratchpad/ 
garbage/source/java/org/apache/garbage/serializer/XHTMLSerializer.java? 
rev=1.3&view=auto

It's in the scratchpad.

	Pier