Forum Moderators: open

Message Too Old, No Replies

Why doesn't my XHTML break IE?

IE isn't supposed to be able to read application/xhtml+xml

         

CtrlAltDimension

8:50 pm on Oct 13, 2005 (gmt 0)

10+ Year Member



I have a bit o' code that's being interpreted admirably by Internet Explorer, but it shouldn't be. It should be prompting a download. Why does this work for me in every browser I've tested, when it should only work in Mozilla?

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>My Site</title>
<meta http-equiv="content-type" content="application/xhtml+xml;charset=iso-8859-1" />
</head>

IE shouldn't be reading the application/xhtml+xml content-type.

Instead of asking what in wrong, I'm wondering why everything is right!

Robin_reala

9:25 pm on Oct 13, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Because the meta isn't good enough - when the heading information and a meta tag differ the browser will (theoretically) take the info from the header. You need to actually set the server up to send the files with that content type. In Firefox you can check the mime type with Tools / Page Info.

CtrlAltDimension

9:42 pm on Oct 13, 2005 (gmt 0)

10+ Year Member



I see. So then what's the point of putting the meta in there if it's all determined by the server in the first place?

Robin_reala

10:55 pm on Oct 13, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In case the server isn't configured to send that data out (in which case the browser will fall back to the meta element as far as I understand it). It does make some sense. For example, the application/xhtml+xml media type makes Firefox (and other most other browsers) use an XML parser instead of the normal 'tag soup' parser. To see the meta element that browser must have already started parsing the page, so it would have to revert back if it had started with the wrong one.

bromley21

12:29 pm on Oct 14, 2005 (gmt 0)



If you're really keen you can get your server to check the "Accept" header sent by the browser, to see if it accepts "application/xhtml+xml", and if so, serve up your pages as that. Otherwise serve them up as "text/html".

Pretty easy to do if you have a dynamic site - I'm not sure if you can do it with Apache.

Bernard Marx

12:48 pm on Oct 14, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This doc [w3.org] says that one can't do this kind of content negotiation, using only a single resource, without "breaking rules". I'm not saying it's true, mind.

A good few sites are serving "application/xhtml+xml" to those that accept it, somehow or other.

Doing this with a small snippet of PHP to chnage the content-type seems to work fine, but that may add a layer of server processing that you don't want.

CtrlAltDimension

2:16 pm on Oct 14, 2005 (gmt 0)

10+ Year Member



Ah, I see. Thanks for the help. I'm starting to like this forum already.