Jump to content
Xisto Corporation
bjrn

Html And Xhtml serving the right kind

Recommended Posts

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?

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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 :D

Share this post


Link to post
Share on other sites

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".

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.