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?
12 Comments
Sorry, the comment form is closed at this time.



November 27th, 2005 at 1:27 am
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.
November 27th, 2005 at 7:37 am
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! :-(
November 27th, 2005 at 5:38 pm
The validator might not have
application/xhtml+XMLin itsAccept: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, notacronym. It is also Extensible and not eXtensible.November 27th, 2005 at 6:49 pm
It must, because Jeremy Keith’s Adactio validates as XHTML 1.1 just fine. I must be doing something wrong somewhere. :-(
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.
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.
November 27th, 2005 at 10:00 pm
It doesn’t, it only checks the doctype. The way around this is to check for the validator and send it the other doctype.
November 27th, 2005 at 10:05 pm
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.
November 28th, 2005 at 9:21 pm
Why is it Extensible and not eXtensible when describing XML/XHTML?
If it were Extensible, shouldn’t the acronyms be EML/EHTML respectively? Cheers :)
November 28th, 2005 at 9:47 pm
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. ;-)
December 1st, 2005 at 12:36 pm
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!
December 1st, 2005 at 1:03 pm
Daniel,
Awesome! I’ll be sure to check out your plugin!
April 26th, 2006 at 12:57 am
[...] 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). [...]
May 12th, 2006 at 11:13 am
[...] 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 [...]