Welcome to WebmasterWorld Guest from 18.206.48.142

Forum Moderators: open

Message Too Old, No Replies

Serving application/xml media type to IE - successfully

     
3:37 pm on Mar 24, 2007 (gmt 0)

Senior Member

WebmasterWorld Senior Member tedster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:May 26, 2000
posts:37301
votes: 0


I just ran across this at the W3C. It was new to me so I thought others might be interested.
From [w3.org...]

Does Microsoft Internet Explorer accept the media type application/xhtml+xml?

No. However, there is a trick that allows you to serve XHTML1.0 documents to Internet Explorer as application/xml.

Include at the top of your document the line in bold here:

<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet type="text/xsl" href="copy.xsl"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

where copy.xsl is a file that contains the following:

<stylesheet version="1.0"
xmlns="http://www.w3.org/1999/XSL/Transform">
<template match="/">
<copy-of select="."/>
</template>
</stylesheet>

Note that this file must be on the same site as the document referring to it.

Although you are serving the document as XML, and it gets parsed as XML, the browser thinks it has received text/html, and so your XHTML 1.0 document must follow many of the guidelines for serving to legacy browsers.

Your XHTML document will continue to work on browsers that accept XHTML 1.0 as application/xml.

11:49 am on Mar 25, 2007 (gmt 0)

New User

10+ Year Member

joined:Mar 25, 2007
posts:8
votes: 0


convert xml to html?
1:06 pm on Mar 25, 2007 (gmt 0)

Senior Member from CA 

WebmasterWorld Senior Member encyclo is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Aug 31, 2003
posts:9074
votes: 6


I've seen this method mentioned before buried in an earlier thread about XHTML [webmasterworld.com], however it's a good reminder that the potential exists to serve XHTML as XML to IE.

I'm not sure there are many advantages compared to simply serving the markup as

text/html
to IE. The XSL transformation changes the XML to HTML, so you're still restricted to using just HTML markup in the document. Using
application/xml
rather than the recommended
application/xhtml+xml
is less than ideal too.

It does however add another option rather than using server-side scripting if you want to experiment with "ultra-strict" XHTML and still have a semblance of cross-browser support.

7:59 pm on Mar 29, 2007 (gmt 0)

New User

10+ Year Member

joined:Jan 16, 2007
posts:1
votes: 0


Using application/xml rather than the recommended application/xhtml+xml is less than ideal too.

LOL. Understatement of the day!

Carol

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members