Skip to content

ara pehlivanian

Web Standards, Web Culture, Web Everything.™

I’ve converted to application/xhtml+xml

So I’ve gone ahead and decided what to do about my dilemma. I’m now serving my pages using the application/xhtml+xml MIME type to compliant browsers and the text/html MIME type to everything else. In order to be able to do this, I installed a wonderful little plugin called WP Content Negotiator written by Admiral Justin. It feels like I just got my first tattoo. It’s a combination of feeling like “wow, I did it!” and “oh boy, I hope I don’t regret this.”

I have to say though that I really learned the meaning of the expression “be careful what you wish for.” A while ago in my post Invalid markup: does it matter? I was complaining about how we should have zero tolerance for invalid markup, and that browsers were too lax with tag soup. Well, let me tell you, installing this plugin was a slap in the face for yours truly. If ever there was a surefire way to break my site right quick, this was it. Colour me shamed. I also learned another valuable lesson: “never install plugins directly on the production version of your site, you’ll most likely break it.”

So there I was, with this giant error message staring me down because the XML parser I had just invoked in Firefox didn’t like my markup. Horror of horrors, I just realized that I couldn’t get by with even one error in my markup. So a little nail-biting, and some quick fixes later, the site is fully XHTML 1.1 Strict served with the application/xhtml+xml MIME type. Not without some consequences however. For example, I can no longer run AdSense or Technorati JavaScripts because of the way they try to write to the DOM. It just doesn’t work the same way with the XML DOM and I have yet to figure out what to do about it. Unfortunately, according to Alex Stevenson’s experience, it seems that Google isn’t about to fix the AdSense XHTML compatibility problem.

It’s a very awkward feeling though, to know that at any given moment, a lapse in my markup will cause a page to stop working. Of course, you might be asking yourself: “why do something like that?” Well, like I told a friend earlier today, “my site is my indulgence, and it’s where I can exercise my purist tendencies.” Sure it’s fanatical to a fault, but hey, where else am I going to have the fun of experimenting with the new and chic? Besides, I can always go back to boring old text/html whenever I want. But where’s the challenge in that?

Sphere: Related Content

  • Comments closed

Buy my book

The Art & Science of JavaScript / SitePoint
The Art & Science of JavaScript

Advertisement

Firebug - Web Development Evolved

Advertisement

12 Comments

  1. Gravatar for Admiral JustinAdmiral Justin says:

    There’s a hack where you write the adsense code into a seperate page and include it as an object. Mail me if you want help with the code.

    BTW, thanks for using my plugin, even though I haven’t updated it recently.

  2. Gravatar for AraAra says:

    Admiral: I’ve been trying to work on a script that overrides the document.write() method that’s the main problem with AdSense (and Technorati). Not much luck so far.

    Thanks again for the plugin. I’m having some trouble though, I’ve got it at XHTML 1.1 (despite setting it to 1.0 earlier) and the validator still only sees it as 1.0! :-(

  3. Gravatar for Anne van KesterenAnne van Kesteren says:

    The validator might not have application/xhtml+XML in its Accept: header.

    XHTML 1.1 is a bit older than XHTML 1.0 though and really has no benefits at the moment. (Some disadvantages and some small errors.)

    And really, XML should be marked up with abbr, not acronym. It is also Extensible and not eXtensible.

  4. Gravatar for AraAra says:

    The validator might not have application/xhtml+XML in its Accept: header.

    It must, because Jeremy Keith’s Adactio validates as XHTML 1.1 just fine. I must be doing something wrong somewhere. :-(

    XHTML 1.1 is a bit older than XHTML 1.0 though and really has no benefits at the moment. (Some disadvantages and some small errors.)

    Well according to my research, XHTML as a rule doesn’t bring any advantages to the average website. I’m just doing it because it appeals to my obsessive compulsive/perfectionist side. But errors in 1.1 might desuede me from using it.

    And really, XML should be marked up with abbr, not acronym. It is also Extensible and not eXtensible.

    Actually—as far as the English language goes—an abbreviation and an acronym are two different things. For example ”dest.” is an abbreviation for ”destination” and ”AJAX” is an acronym for ”Asynchronous Javascript And XML.” Unfortunately the plugin that I use to automatically wrap acronyms and abbreviations—which also outputs eXtensible instead of Extensible, which I should change—doesn’t differentiate between the two. On top of which, the comment filter adds acronym tags and then WordPress does the same when rendering so I get double nested acronym tags! *sigh* What a mess. Like they say, ”if you want it done right, you’ve got to do it yourself.” I just don’t know if I have the time to write all my own plugins and scripts.

  5. Gravatar for Admiral JustinAdmiral Justin says:

    The validator might not have application/xhtml+XML in its Accept: header.

    It doesn’t, it only checks the doctype. The way around this is to check for the validator and send it the other doctype.

  6. Gravatar for AraAra says:

    It doesn’t, it only checks the doctype. The way around this is to check for the validator and send it the other doctype.

    Oh. Well then that explains it. I don’t think I read Anne’s comment closely enough. For some reason I thought he meant that the validator was making a distinction between XHTML versions, instead of accepting the application/xhtml+XML MIME type. Oops. My bad.

  7. Gravatar for Steve WilliamsSteve Williams says:

    Why is it Extensible and not eXtensible when describing XML/XHTML?

    If it were Extensible, shouldn’t the acronyms be EML/EHTML respectively? Cheers :)

  8. Gravatar for AraAra says:

    Well, the proper form is to write it ”Extensible,” however ”eXtensible” places the emphasis on the first sound and not the first letter of the word. So, really, you’re both right. And really, XML sounds a lot cooler than EML. ;-)

  9. Gravatar for Daniel Doro FerranteDaniel Doro Ferrante says:

    Hi Ara,

    I use my blog for physics and math and science stuff in general… so, naturally, the need for MahtML appeared. Therefore, the need for correct MIME types was as strong as ever. ;)

    I ended up trying ALL WP plugins that do ”content negotiation” in a form or another… but neither of them made me quite happy… so, sure enough, i’ve written my own: WP-XHTML-mime.php (i also have an entry in my blog pseudo-explaining this: Setting the correct MIME type). I haven’t had time, yet, to post the plugin in the appropriate sites nor to write a static page with all the proper explanations… but, i hope you’ll understand.

    Please, feel [more-than-]free to contact me with BUGS or improvements. :)

    Cheers, []’s!

  10. Gravatar for AraAra says:

    Daniel,

    Awesome! I’ll be sure to check out your plugin!

  11. Gravatar for Hacking the Technorati Badge or: How I Hacked Document.Write() in Order to Make it Work With application/xhtml+xml | ara pehlivanian—Web Standards, Web Culture, Web Everything.™Hacking the Technorati Badge or: How I Hacked Document.Write() in Order to Make it Work With application/xhtml+xml | ara pehlivanian—Web Standards, Web Culture, Web Everything.™ says:

    [...] The first thing I noticed when I switched to application/xhtml+xml was how unforgiving the XML parser is with badly formed markup. It stops parsing and displays a big fat red error message where your page is supposed to be. The second thing I noticed was how my nifty little third party JavaScript includes all stopped working. I’m talking of course about my AdSense ads and my Technorati Badge (which is now back in my footer thank-you-very-much). [...]

  12. Gravatar for document.write() fix for (real) XHTML | ara pehlivanian—Web Standards, Web Culture, Web Everything.™document.write() fix for (real) XHTML | ara pehlivanian—Web Standards, Web Culture, Web Everything.™ says:

    [...] It’s been brought to my attention that it may not be clear as to why I’ve written this script. Well this is a niche problem for those who serve pages using the application/xhtml+xml MIME type–i.e. real XHTML. To learn more about this issue read: Does document.write work in XHTML? and Why document.write() doesn’t work in XML [...]

Sorry, the comment form is closed at this time.

Skip to navigation

More stuff by Ara elsewhere on the web

    Snook Approved!

    © 2005-2008, Ara Pehlivanian.

    Stock photography courtesy stock.xchng. This site uses Akismet to catch spam (54,743 caught since May 2006) is hosted by DreamHost and powered by WordPress.