Serving XHTML to browsers that support it

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Serving XHTML to browsers that support it

Eric van der Vlist
Hi,

I am revisiting this issue and have uncommented the relevant piece in
epilogue-servlet.xpl.

This is working rather fine, but it shouldn't!

The test to check if a browser accepts XHTML is:

            <p:choose href="#request">
                <p:when test="contains(/request/headers/header[name = 'accept'], 'application/xhtml+xml')">
 
Most browsers (Firefox, Opera, Lynx) do send an explicit list of media
types that they accept, but when you look at the headers sent by IE, you
get something such as:

GET /orbeon/xmlfr/actualites/planete/xmlfr/fr/ HTTP/1.1
Accept: */*
Accept-Language: fr
Accept-Encoding: gzip, deflate
If-Modified-Since: Mon, 24 Dec 2007 08:52:18 GMT
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows 98)
Host: localhost:8080
Connection: Keep-Alive
Cookie: JSESSIONID=E2F23C7A8248558C9D0F38B5896A0F0B

"Accept: */*" is a valid HTTP accept header that should be interpreted
as "accept anything including application/xhtml+xml and if the test
happen to work in the case of IE, it could fail if a browser that
supports application/xhtml+xml was using a wildcard.

Furthermore, if the same test was done to detect if a browser supports
text/html its answer would be no for IE :) !

Also, rfc2616 says that "If no Accept header field is present, then it
is assumed that the client accepts all media types".

To be more robust, the test should be something such as :

contains(/request/headers/header[name = 'accept'], 'application/xhtml+xml')
or contains(/request/headers/header[name = 'accept'], 'application/*')
or contains(/request/headers/header[name = 'accept'], '*/*')
or not(/request/headers/header[name = 'accept'])

which according to rfc2616 is the right way to test if a user agent
supports application/xhtml+xml.

A specific test should then be added to detect IE based on the user
agent header since we all know that IE doesn't support application/xhtml
+xml even if it does pretend so!

Eric
--
GPG-PGP: 2A528005
Carnet web :
                                      http://eric.van-der-vlist.com/blog
------------------------------------------------------------------------
Eric van der Vlist       http://xmlfr.org            http://dyomedea.com
(ISO) RELAX NG   ISBN:0-596-00421-4 http://oreilly.com/catalog/relax
(W3C) XML Schema ISBN:0-596-00252-1 http://oreilly.com/catalog/xmlschema
------------------------------------------------------------------------


--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws

signature.asc (196 bytes) Download Attachment