Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

OT: How do you serve up XHTML?

by wfsp (Abbot)
on Sep 15, 2007 at 13:59 UTC ( #639170=perlquestion: print w/ replies, xml ) Need Help??
wfsp has asked for the wisdom of the Perl Monks concerning the following question:

More accurately: if you serve up XHTML which mime type do you use?

Ian Hickson argues that Sending XHTML as text/html Considered Harmful.

Brad Fults, in: Sending XHTML as text/html Considered Harmful to Feelings, is not convinced.

The www.w3.org themselves seem to agree: Why is it allowed to send XHTML 1.0 documents as text/html?

What really attracted my attention was, as Ian Hickson suggests, opening http://www.mozillaquestquest.com/ in IE. It does indeed show a DOM tree (in IE7 as well as the IE6 that he mentions).

This was compounded by the apparent attitude of w3.org (excerpts from the link above):

Which browsers accept the media type application/xhtml+xml?
... In fact, any modern browser. ...

Does Microsoft Internet Explorer accept the media type application/xhtml+xml?
No. ...
Have I misunderstood something here? To my reading those statements could be considered contradictory.

The w3.org then describes a "a trick that allows you to serve XHTML1.0 documents to Internet Explorer as application/xml." It involves adding:

<?xml-stylesheet type="text/xsl" href="copy.xsl"?>
to every XHTML file and for the site to have the following file:
<stylesheet version="1.0" xmlns="http://www.w3.org/1999/XSL/Transform"> <template match="/"> <copy-of select="."/> </template> </stylesheet>
w3.org explain that:
Although you are serving the document as XML, and it gets parsed as XML, the browser thinks it has received text/html, and so your XHTML 1.0 document must follow many of the guidelines for serving to legacy browsers.
"Standards" that need "tricks" to work (for some definition of work) in a popular browser.

I find all this scary. I'm in favour of adhering to the latest standards and I bought into the idea of XHTML for all the reasons w3.org put forward. I have spent a lot of time and effort refactoring a medium sized website to validate against XHTML (amongst other things).

I must admit that at the moment I think Ian Hicks has the right idea:

Authors who are not willing to use one of the XML MIME types should stick to writing valid HTML 4.01 for the time being. Once user agents that support XML and XHTML sent as one of the XML MIME types are widespread, then authors may reconsider learning and using XHTML.
The website I maintain has a non-techie audience and ignoring IE (however tempting that may be) is clearly not an option.

Do you serve up HTML or XHTML? If the latter, which mime type do you use?

Comment on OT: How do you serve up XHTML?
Select or Download Code
Re: OT: How do you serve up XHTML?
by Joost (Canon) on Sep 15, 2007 at 14:42 UTC
    Internet Explorer 7 may be recent, but I wouldn't call it modern. The XHTML issue is only the tip of the iceberg. Once you start using "modern" standards (almost everything created after 1998; CSS 2, PNGs with alpha channels, transparency in general, JavaScript event handlers, etc etc) you'll run into all kinds of problems that require very specific IE kludges if they can be solved at all.

    Anyway, I mainly serve up HTML 4.01 strict, but when I do go for XHTML I usually just send it as text/html, since it's often the easiest way to get it to work "everywhere". YMMV. Is there any specific reason you want to go for XHTML at all?

Re: OT: How do you serve up XHTML?
by samtregar (Abbot) on Sep 15, 2007 at 17:41 UTC
    "Standards" that need "tricks" to work (for some definition of work) in a popular browser. I find all this scary.

    You must be new here, huh? Many W3C standards need "tricks" to work in IE. Prime example: CSS. Great stuff, but you'll definitely need to learn some tricks to get it to work on IE!

    I bought into the idea of XHTML for all the reasons w3.org put forward.

    For what it's worth, I haven't. I do use XHTML, primarily when working on Petal templates for MKDoc. It's a royal pain compared to working with HTML - the slightest minor error and the whole page fails to parse. XML is just too finicky and verbose for my taste as a markup language.

    I'm sure I use text/html to serve XHTML, but I can't honestly say I ever thought about it much.

    -sam

Re: OT: How do you serve up XHTML?
by Cap'n Steve (Friar) on Sep 16, 2007 at 07:39 UTC
    I've been struggling with the same philosophical problem. I want to do things the best, most standard way, even if it's just for bragging rights, but I can't find any real benefits. I have a .htaccess file that almost always sends the correct Content-type to each browser, but I've given up on using it for now. All I know so far is that serving up content the proper way breaks a lot of Javascript.
Re: OT: How do you serve up XHTML?
by moritz (Cardinal) on Sep 16, 2007 at 10:21 UTC
    My web apps usually produce xhtml 1.0 strict, and the content type in the header is determined by the client's Accept-header.

    If the client has a higher q=-score for application/xhtml+xml then for text/html I send the application/xhtml+xml header.

    If not, I regretfully fall back to text/html.

Re: OT: How do you serve up XHTML?
by ww (Bishop) on Sep 16, 2007 at 21:15 UTC
    Re...
    ...the apparent attitude of w3.org (excerpts from the link above):

        Which browsers accept the media type application/xhtml+xml?
        ... In fact, any modern browser. ...

        Does Microsoft Internet Explorer accept the media type application/xhtml+xml?
        No. ...


    Have I misunderstood something here? To my reading those statements could be considered contradictory.

    The comments, above, from Joost and samtregar may be sufficiently illuminating, but to be very explicit, the "powers that be" at w3c do indeed appear to have an "attitude" (and, IMHO, one that's largely justified) about M$' longstanding practice of releasing browsers (among other products) that don't comply with existing standards whether by failing to implement some of those or by trying to sell the public on the notion that its proprietary extensions/modifications of a standard represent the "one true standard."

    A cursory review of the literature (appropo the standards compliance of IE or appropo "cross browser (in)compatibilities) will show that the two statements you cite are not actually contradictory, but actually, reinforce one another, given the w3c view that IE 5 and 6 fail to even approach its definition of a "modern" browser.

    As to what I serve, it's almost always HTML 4.01 (strict or transitional), unless there is some exceptionally good reason to use capabilities of XHTML. Most of my clients are NOT using their websites in ways where XHTML clearly offers net*1 advantages

    *1 No pun intended; please read the phrase as having an economic tilt.

      While it's true Microsoft has a bad record when it comes to playing nicely with others, W3C has a history of useless standards. If not for proprietary extensions, I think innovation on the web would be long dead.

        W3C annoys me by creating standards that no UA will ever, ever, implement. Sometimes they are impractical, sometimes they try to make xhtml/css duplicate functionality of a better solution.

        IE vexes me not so much because of proprietary extensions or standards breaking, but because what they decide to break isn't intuitive to me. Things I expect to work fail; Things I expect to fail somehow work.

        All in all, though, I think we've got it better in this generation than we have before. Some of these issues are still a pain to deal with, but I recall it often took herculean effort to make even minor functionality work in all the UAs out there.

Re: OT: How do you serve up XHTML?
by amarquis (Curate) on Sep 17, 2007 at 13:20 UTC

    With web stuff, feelings I have about the value of standards take a backseat to "getting the damn thing working and out the door." That being said, I send XHTML with the text/html mime type.

    I prefer XHTML because it is cleaner to work with, and I send as text/html because it most often works.

    As far as W3C and Microsoft beating their chests at one another, I've lived through plenty of that. Sometimes I agree philosophically with Microsoft, more often I agree with the W3C. But it doesn't much matter when what I'm sending out the door is the practical solution, not the one that makes me feel warm and fuzzy.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://639170]
Approved by Joost
Front-paged by derby
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (8)
As of 2014-09-21 07:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (167 votes), past polls