The X-Philes

Friday, December 5, 2003 at 1:53 pm | Comments off

I've decided to try submitting my site to the X-Philes. I'm not all that framiliar with it, but Robert Wellock pointed me to his submission and it peaked my curiosity. So, after making a few simple changes to my site, it's ready to go. Most notably, I had to serve my XHTML with the application/xhtml+xml MIME type to conforming user agents, and text/html to the rest (including all versions of IE). For the time being, I simply used a bit of PHP in my header to detect if the browser claimed to be able to handle application/xhtml+xml by reading the HTTP header HTTP_ACCEPT. It's really quite simple, and the code I used looks like this:

<?PHP
# send application/xhtml+xml to conforming browsers
if (stristr($_SERVER["HTTP_ACCEPT"],"application/xhtml+xml")) {
	header("Content-type: application/xhtml+xml");
}
# and text/html to non-conforming browsers
else {
	header("Content-type: text/html");
}
?>

Now, before anyone reading this decides to send their documents as application/xhtml+xml, you should be aware that your documents must be well formed. You need to close all tags, use lowercase for your elements and attributes, correctly nest tags, etc. Any errors in your code will result in an XML parsing error, rather than degrading gracefully as we are used to. This is, in my opinion, a great benefit - it's time to convert from slop markup to a stricter, better way!

Comments

Robert Wellock
December 9th, 2003
1:36 AM | #

Plus JavaScript may have to be used via the XML DOM or HTML DOM depending upon how you have served the document.

I hope you've made the weblog robust enough so I cannot break it when you serve it as an application of XML!?

Ryan
December 9th, 2003
1:47 AM | #

All (X)HTML tags are removed, as the < and > are changed to their character entities. If you know of a possible way to break it, by all means let me know what they are so I can attempt to fix any problems. :)

Robert Wellock
December 9th, 2003
5:50 AM | #

Lorem Ipsum <LoremIpsum> <Lorem Ipsum> <Lorem Ipsum />...

Robert Wellock
December 9th, 2003
5:53 AM | #

Erm...

[b]bold (strong) text[/b] produces bold (strong) text
italic (emphatic) text[/i] produces italic (emphatic) text
underlined text produces underlined text.

Robert Wellock
December 9th, 2003
6:00 AM | #

It seems alright now that you removed the option to add (x)html elements I just had to make sure.

I think you'll pass and get added within the next few weeks if you have sumbitted.

Ryan
December 9th, 2003
8:17 AM | #

Thanks for looking at it. :)

I have submitted, and will be sure to post an update, if/when it get's accepted.

Evan
December 10th, 2003
12:29 AM | #

Looks good, Ryan. I've added you to the list.

http://www.goer.org/Markup/TheXPhiles/

You're living on a knife's edge now, so keep up the good work... :)

Meint
December 10th, 2003
4:56 AM | #

Hi Ryan,

Concerning your mime type detection, you might be interested in the following article: http://keystonewebsites.com/articles/mime_type.php

It shows a well thought out approach to serving the correct mime type to browsers, your current approach is to simple (this isn't meant as a derogatory comment :-). Your current approach for instance will show your pages as application/xhtml+xml to Opera, which isn't really XHTML 1.1 compliant. Using the PHP snippet from keystone will introduce the q (=quality) argument in the decision whether to serve text/html or application/xhtml+xml.

I augmented it myself by including user agent detection for the W3C validator so it gets XHTML 1.1 served (the keystone snippet doesn't detect W3C validator as application/xhtml+xml capable).

Cheers,

Meint

Ryan
December 10th, 2003
3:30 PM | #

Evan - Awesome! Thanks.

Meint - I've been thinking about doing something similar. I would probably detect which browsers support XHTML and send them the XHTML 1.1 page (with the application/xhtml+xml MIME type) and HTML 4.01 Strict to the browsers that do not. We shall see. Thanks for the input!

Simon Jessey
December 10th, 2003
4:55 PM | #

Regarding the article on Keystone Websites, the reason the detection of the W3C validator was left out (it was in originally) is that I made a conscious decision to avoid specific user agent detection.

Meint
December 11th, 2003
3:48 AM | #

Simon - I wouldn't have done it otherwise myself or else the script would have become very convoluted :-)

Ryan - It's probably easier to serve XHTML 1.0 Strict to non-conforming browsers, you may serve that with text/html and you don't need to change anything in the markup and/or styling.

The site I'm currently working on does this (http://www.orionun2315.nl/mambo/test/, I didn't do the graphic design :-)

<form></form><xmnl[<><bold><strong><]
December 30th, 2003
5:29 PM | #

not spam trying to break ur code

Comments are automatically closed after 45 days