I'm wrapping up applyxslt, a WSGI middleware module to serve separate XML and XSLT to browser that can handle it (using the stylesheet PI. For browsers that can't it would intercept the response and perform the XSLT transform for the browser, sending on the result. BTW, for more on WSGI Middleware, see “Mix and match Web components with Python WSGI”.
My biggest uncertainty is the best way to determine whether a browser
can handle XML+XSLT. I doubt anything in the Accept
header would
help, so I'm left having to list all User-Agent
strings for browsers
that I know can handle this (basically Firefox, Opera, and recent
Mozilla, Safari and MSIE).
So far I'm deriving my User-Agent
list from several sources, including
- Wikipedia (the daddy of all User-Agent lists I've seen)
- "Masquerading Your Browser", by Eric Giguere (the "Common User-Agent Values" section) and
- "Understanding user-agent strings"
Really the Wikipedia list is all I needed, but I found and worked with the other ones first.
So based on that here is the list of User-Agent string patterns I am treating as evidence the browser does understand XML+XSLT (Python/Perl regex):
.*MSIE 5.5.* .*MSIE 6.0.* .*MSIE 7.0.* .*Gecko/2005.* .*Gecko/2006.* .*Opera/9.* .*AppleWebKit/31.* .*AppleWebKit/4.*
Note: this hoovers up a few browser versions I'm not entirely sure of: Minimo, AOL Explorer and OmniWeb. I'm fine with some such uncertainty, but if anyone has any suggestions for further refinement of this list, let me know. I'd like to keep it updated.