HOME       >>       Programming

Html And Xhtml serving the right kind


bjrn

Right now I have a site, which I've made XHTML 1.0 Strict. I am sending it as application/xhtml+xml to browsers that say they can handle it, and as text/html to all other browsers. Anyway, I started thinking that I'd much rather send proper HTML 4.01 to browsers that don't understand XHTML instead of XHTML pretending to be HTML 4.01.

It's not really a problem with IE, because it is made to handle badly written sites, but who knows, some browser that can handle HTML, but not XHTML, may be (correctly) parsing

<p> Hello <br /> World </p>
as
<p> Hello <br>> World </p>

So I was wondering: Is there anyone here who stores their content as XML perhaps (or anything else) and transforms it in some way (with XSLT or anything else)?

Any ideas of how I would go about generating an XHTML and a HTML version from one base format. Or perhaps transform XHTML into HTML?

Xedos

I don't get you.Do you mean something like differrent pages displayed for diffrerent browers that can support them?I think javascript can do that.


bjrn

Yeah. Internet Explorer doesn't understand XHTML, so I would like to have something that can convert XHTML to HTML (or similar). And then when a visitor comes to my site I check if their browser can handle XHTML, and if not, I show them the HTML page.I can't do it with JavaScript though. Because if I am showing them the HTML page I am sending it with a text/html MIME type, but if I am sending the XHTML page I am not sending it as text, but as application/xhtml+xml (for lots of difficult reasons).So I really need something server-side


BoSZ

Yeah. Internet Explorer doesn't understand XHTML,

48246[/snapback]

bro with all my hate to Ie i have to say taht what you had said is far from the thruth

 

most browsers render Xhtml


8bit

Whats wrong with IE? I have to use it cause Mozilla won't come up.


bjrn

bro with all my hate to Ie i have to say taht what you had said [that IE doesn't understand XHTML] is far from the thruth

No it doesn't. When IE sees XHTML it says: "Wow. I have no idea what this is, so I guess it must be HTML 4 or something like that".[1] So although it looks like it understands XHTML, it's really only treating XHTML as if it were badly written HTML. Furthermore it doesn't understand the mime type application/xhtml+xml (which XHTML should be sent as by the server). I must admit that I've been hearing rumours that IE under WinXP SP2 can handle XHTML properly-ish.
Anyway, I'm still looking for something to either convert XHTML 1.1 to HTML 4.01 or XML to XHTML 1.1 and HTML 4.01 or something like that.


[1] Actually, it's a bit more complex than that, when IE gets a document it checks the 250 bytes of the document to guess what kind of document it is. IE does this because it wants catch things which are being sent with the wrong mime type by wrongly/uncarefully configured servers. IE doesn't really trust MIME types, it wants to decide for itself. So say you have a text document, full with HTML tags, but you want to show it as plain text. So, you think that sending it as text/plain would do it, but it doesn't. IE looks through the document, sees the tags and thinks "hah! the sever must have made a mistake" and shows the document as a HTML document, and not as a text document as you wanted it.

Roly

I do what you do, send the MINE type application/xhtml+xml to browsers who support it but I've never had your problem. Or I've never noticed it before o_O


Taupe

Yes, bjnr is right : IE doesn't support XHTML.

You might want to have a look to this script.




RGPHNX

So whats the definitive last word? Does IE handle XHTML -NO? If not, is there a script format/language converter program to solve this problem. That was the original question, I believe. Anybody know ? the second question was, For multi webbrowser compatibility is there a server side app. that solves this problem?Anybody know??RGPHNX


bjrn

This PHP script is what I am using right now for MIME types:

if (stristr($_SERVER['HTTP_ACCEPT'], "application/xhtml+xml")) {  header("Content-Type: application/xhtml+xml; charset=utf-8");} else {  header("Content-Type: text/html; charset=utf-8");}
So I am sending my pages as application/xhtml+xml to those browsers that claim to understand it. I guess I should do another check because browsers are technically allowed to send along a "quality" parameter to indicate how well they support a format. So a browser could send something like "application/xhtml+xml q=0.1" (not quite sure about the format) in the accept header, indicating that it only supports it to a very small degree. It's a minor point though.

 

 

But what I really want is to not just send XHTML as text/html and pretend it's HTML. I actually want to transform my pages for browsers that don't understand XHTML. I'm considering saving my pages in XHTML 1.1 and then having a regex run through it to convert it to HTML 4.01 for older browsers.

 

Edit: Just started reading the page Taupe linked to. It's looking just like what I was looking for, thanks Taupe


FirefoxRocks

I don't use PHP, therefore I can't transform the MIME type.If there is another way to change to "application/xhtml+xml", please tell me how to.I really want my XHTML 1.1 pages to be truly XHTML 1.1, not "text/html".


Saint_Michael

I like to make a small correction IE 6 doesn't handle most xhtml you need ot have IE 7 since that browser is xhtml xml complient.



VIEW DESKTOP VERSION REGISTERGET FREE HOSTING

Xisto.com offers Free Web Hosting to its Members for their participation in this Community. We moderate all content posted here but we cannot warrant full correctness of all content. While using this site, you agree to have read and accepted our terms of use, cookie and privacy policy. Copyright 2001-2019 by Xisto Corporation. All Rights Reserved.