By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,648 Members | 1,198 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,648 IT Pros & Developers. It's quick & easy.

how to switch on Standards-compliant mode for IE6 when using thetrick w3 provided for serving xhtml as application/xml to IE

P: n/a
http://www.w3.org/MarkUp/2004/xhtml-faq provided a trick to serve xhtml
webpage to IE as application/xml

I used that trick and now every one of my xhtml webpage have following
first 4 starting lines:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="curseIE.xsl"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

The second line is used to tell Internet Explorer to treat this page as
html, as a workaroudn suggested by w3.org (curseIE.xsl is a file in the
same directory).

however now the page is rendered in BackCompat mode. I don't understand.
Because a lot of layout is already designed with CSS box model in mind, I
need IE to render it in the Standards-compliant mode ("Standards-compliant
mode" is the terminology used by MSDN I just copy it over). As stated in
this MSDN article:
http://msdn.microsoft.com/workshop/a...ts/doctype.asp
The standard compliant mode is switched on if DOCTYPE is XHTML (which is
true for my webpages)

I also read that some people suggest not to put <?xml ...?as the first
line because that makes IE switch off Standards-compliant mode. Well, so I
removed <?xml ... ?>, result? Standards-compliant mode is still switched
off, tested by using
javascript:alert(document.compatMode);

So is it possible at all to use w3's trick to server xhtml to IE and at
the same time make the page render in Standards-compliant mode?

Thanks a lot in advance!
Jan 23 '07 #1
Share this Question
Share on Google+
15 Replies


P: n/a
Zhang Weiwu wrote:
http://www.w3.org/MarkUp/2004/xhtml-faq provided a trick to serve xhtml
webpage to IE as application/xml

I used that trick and now every one of my xhtml webpage have following
first 4 starting lines:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="curseIE.xsl"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

So is it possible at all to use w3's trick to server xhtml to IE and at
the same time make the page render in Standards-compliant mode?
Try the proper Doctype:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

--
Gus
Jan 23 '07 #2

P: n/a

Zhang Weiwu wrote:
http://www.w3.org/MarkUp/2004/xhtml-faq provided a trick to serve xhtml
webpage to IE as application/xml
There are three ways to serve XHTML to IE

1. Use HTML instead ! (best)

2. Appendix C of the W3C XHTML 1.0 specification (as Gus described, a
usable choice)
- Use XHTML 1.0 Strict
- Send a text/html content-type header, not an XML content type
- Make sure the doctype declaration is the first content in the
document, without any XML prolog or XSLT stylesheet reference.

3. Send XML and XSLT (As the W3C described on the page you cited, not a
good choice)
This has little to do with HTML, you're sending an XML document and
turning it into HTML at the client-side. The fact that it was already
XHTML to begin with doesn't matter, although it does make the XSLT
stylesheet simple.
To get 3. to work in standards rendering mode, then you need to make
sure the output of the XSLT transform has an appropriate doctype. Use
the <xsl:outputelement like this:

<xsl:output method="html"
omit-xml-declaration = "yes"
standalone = "yes"
doctype-public = "-//W3C//DTD HTML 4.01 Strict//EN"
doctype-system = "http://www.w3.org/TR/html4/strict.dtd"
cdata-section-elements = "script pre"
media-type = "text/html"
/>

Jan 23 '07 #3

P: n/a
于 Mon, 22 Jan 2007 22:24:31 -0500,Gus Richter写到:
Zhang Weiwu wrote:
>http://www.w3.org/MarkUp/2004/xhtml-faq provided a trick to serve xhtml
webpage to IE as application/xml

I used that trick and now every one of my xhtml webpage have following
first 4 starting lines:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="curseIE.xsl"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

So is it possible at all to use w3's trick to server xhtml to IE and at
the same time make the page render in Standards-compliant mode?

Try the proper Doctype:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
I cannot. That makes all user of my site rely on their connectivity to
w3.org to see MY website. Due to ISP competition (not competing by
providing better access but competing by block other ISP's access) a lot
of Chinese users especially some college students cannot access w3.org
reasonably fast. Now we got a Taiwan earthquake, impossible to fetch this
DTD file for 99% users.
Jan 23 '07 #4

P: n/a
Scripsit Zhang Weiwu:
>Try the proper Doctype:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

I cannot.
Yes you can. Besides, it's what you _must_ do in order to conform to the
XHTML specification (when using Strict, but other DOCTYPE alternatives
require the URL as well). Actually you should use HTML 4.01 instead of XHTML
1.0, but that's not relevant here - HTML 4.01 has exactly the same
"problem".

(And you _can_ trim quotations so that you only quote the relevant part in
the message you are commenting on. Please do so in future.)
That makes all user of my site rely on their connectivity to
w3.org to see MY website.
Of course not. Browsers don't actually _use_ DOCTYPE declarations for
anything else than making their guess on whether the author wants "standards
mode" or "quirks mode".

Just try it. You can even put www.w3.invalid instead of www.w3.org and
browsers won't still notice anything, beyond (perhaps) switching to "quirks
mode" (since the DOCTYPE declaration as a _string_ isn't in their list of
alternatives that trigger "standards" mode).

Besides, even if browsers actually tried to fetch the DTD, they would be
expected to use the first quoted string to find it in their catalog and only
failing that should they use the second quoted string as a URL. Thus, in
this hypothetical situation, the URL string could only help, not hurt.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

Jan 23 '07 #5

P: n/a
于 Tue, 23 Jan 2007 02:08:35 -0800,Andy Dingley写到:
Zhang Weiwu wrote:
>http://www.w3.org/MarkUp/2004/xhtml-faq provided a trick to serve xhtml
webpage to IE as application/xml

There are three ways to serve XHTML to IE

1. Use HTML instead ! (best)
Now I know I should not use XHTML but it's too late already. I am already
warned only "advanced user" will be able to use xhtml, but I *thought* I
am an advanced user (4 year Linux user and 3 year apache admin). Now I
think the trouble doesn't worth... I should have used HTML!
>
2. Appendix C of the W3C XHTML 1.0 specification (as Gus described, a
usable choice)
- Use XHTML 1.0 Strict
- Send a text/html content-type header, not an XML content type
- Make sure the doctype declaration is the first content in the
document, without any XML prolog or XSLT stylesheet reference.
This is the idea I like most, but for my limited apache knowledge I think
this is not possible to activate content negociation for IE unless I
create a .html symbolic link to all my .xhtml files (content negociation
is based on file extension name difference), which is not very practical in
my case (I can certainly do it as a last resort). I knew many php methods
but the current website is all about static pages and perhaps will go on
like this.
>
3. Send XML and XSLT (As the W3C described on the page you cited, not a
good choice)
This has little to do with HTML, you're sending an XML document and
turning it into HTML at the client-side. The fact that it was already
XHTML to begin with doesn't matter, although it does make the XSLT
stylesheet simple.
To get 3. to work in standards rendering mode, then you need to make
sure the output of the XSLT transform has an appropriate doctype. Use
the <xsl:outputelement like this:

<xsl:output method="html"
omit-xml-declaration = "yes"
standalone = "yes"
doctype-public = "-//W3C//DTD HTML 4.01 Strict//EN"
doctype-system = "http://www.w3.org/TR/html4/strict.dtd"
cdata-section-elements = "script pre"
media-type = "text/html"
/>
Thank you a lot for this detailed answer. I hope someone can add this to
teh FAQ of w3 too so that less people are confused. This is currently the
best solution to static xhtml pages.
Jan 23 '07 #6

P: n/a
于 Tue, 23 Jan 2007 17:12:07 +0200,Jukka K. Korpela写到:
[snip]
>That makes all user of my site rely on their connectivity to
w3.org to see MY website.

Of course not. Browsers don't actually _use_ DOCTYPE declarations for
anything else than making their guess on whether the author wants "standards
mode" or "quirks mode".
Please just try it. You already knew the context, that I am trying to ship
xml document to IE and rely on it to treat it as purely xml, call up a XSL
translation and generate an HTML. You knew this context, so it's clear IE
will try to fetch the DTD file (and ent files refered from DTD file). I
have tried it and you can try it too.

I knew browser is expected to not to actually USE doctype declaration, but
does IE often do things you expected? I am surprised to find I must keep
the dtd files on my webserver, too. Acutally browsers should understand
application/xhtml+xml saving all the trouble here but that's IE I am
talking about. (I knew IE never said they support XHTML too.)
Just try it. You can even put www.w3.invalid instead of www.w3.org and
browsers won't still notice anything, beyond (perhaps) switching to "quirks
mode" (since the DOCTYPE declaration as a _string_ isn't in their list of
alternatives that trigger "standards" mode).

Besides, even if browsers actually tried to fetch the DTD, they would be
expected to use the first quoted string to find it in their catalog and only
failing that should they use the second quoted string as a URL. Thus, in
this hypothetical situation, the URL string could only help, not hurt.
I didn't image this problem, I met this problem. I cannot access my own
website myself in the same office if I keep the correct DOCTYPE
decoration, and I had to ask a friend in German to mail me the DTD fiile
and ent files referred from the DTD file. And since I have been doing web
development for some time, I am getting used to try not to do things the
'correct' way but just do whatever makes IE work.
Jan 23 '07 #7

P: n/a

Zhang Weiwu wrote:
1. Use HTML instead ! (best)

Now I know I should not use XHTML but it's too late already. I am already
warned only "advanced user" will be able to use xhtml, but I *thought* I
am an advanced user
I'm sure that you can use it. The problem is if your users and browsers
can use it. It's just a nuisance to get things right so that they do
work and HTML is easier than Appendix C.

2. Appendix C of the W3C XHTML 1.0 specification
This is the idea I like most, but for my limited apache knowledge I think
this is not possible to activate content negociation for IE
You don't need any negotiation, just serve Appendix C to all browsers.
It works fine.

Jan 23 '07 #8

P: n/a
Zhang Weiwu wrote:
于 Tue, 23 Jan 2007 17:12:07 +0200,Jukka K. Korpela写到:
I didn't image this problem, I met this problem. I cannot access my own
website myself in the same office if I keep the correct DOCTYPE
decoration, and I had to ask a friend in German to mail me the DTD fiile
and ent files referred from the DTD file. And since I have been doing web
development for some time, I am getting used to try not to do things the
'correct' way but just do whatever makes IE work.
Even so, you probably still need to use an absolute URL beginning with
"http://". Have you tried that?
Jan 23 '07 #9

P: n/a
Scripsit Zhang Weiwu:
Please just try it. You already knew the context, that I am trying to
ship xml document to IE and rely on it to treat it as purely xml,
call up a XSL translation and generate an HTML.
OK, sorry, I lost the context and though about normal HTML processing in
browsers. Indeed, if you serve your data as XML and include a DOCTYPE
declaration, then browsers _may_ (and often do) retrieve the DTD.
I knew browser is expected to not to actually USE doctype
declaration, but does IE often do things you expected?
Actually browsers _are_ more or less expected to use it in XML context and
would be expected to do so in genuine SGML context, but HTML never was
genuine SGML.
I am surprised
to find I must keep the dtd files on my webserver, too.
Well, that's a different issue and a browser fault, but actually the XHTML
specifications tell you to use a DOCTYPE declaration with a URL. If you
serve an HTML document as application/xml, just referring to the XHTML
"namespace", then you're more or less in a no-man's land between HTML and
generic XML.
And since I have been
doing web development for some time, I am getting used to try not to
do things the 'correct' way but just do whatever makes IE work.
The way that has worked for years and will keep working indefinitely is to
use HTML 4.01. There's no hurry in moving to XHTML at least before IE does.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

Jan 23 '07 #10

P: n/a
Zhang Weiwu <zh********@realss.comwrote:
>http://www.w3.org/MarkUp/2004/xhtml-faq provided a trick to serve xhtml
webpage to IE as application/xml
http://hsivonen.iki.fi/wannabe/
http://www.spartanicus.utvinternet.ie/no-xhtml.htm

--
Spartanicus
Jan 23 '07 #11

P: n/a
Andy Dingley wrote:
You don't need any negotiation, just serve Appendix C to all browsers.
It works fine.
Except in browsers which implement features mentioned in section B.3.3 of
the HTML 4.01 spec, like emacs-w3 before they broke it so it could cope
with all the XHTML being served as text/html.

--
David Dorward <http://blog.dorward.me.uk/ <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Jan 24 '07 #12

P: n/a


On Jan 24, 12:25 am, David Dorward <dorw...@yahoo.comwrote:
Except in browsers which implement features mentioned in section B.3.3 of
the HTML 4.01 spec, like emacs-w3
_Which_ browsers? Apart from emacs-w3 (which is amazingly rare anyway)
I know of _none_ that have a problem with this, and I've been asking
for examples for a couple of years now.

Jan 24 '07 #13

P: n/a
In article <Lc******************@reader1.news.saunalahti.fi >,
"Jukka K. Korpela" <jk******@cs.tut.fiwrote:
I knew browser is expected to not to actually USE doctype
declaration, but does IE often do things you expected?

Actually browsers _are_ more or less expected to use it in XML context
Well, that wasn't the expectation of the writers of the XML spec:
http://www.xml.com/axml/notes/WhyOptExtEnt.html

See also:
http://hsivonen.iki.fi/no-dtd/

--
Henri Sivonen
hs******@iki.fi
http://hsivonen.iki.fi/
Mozilla Web Author FAQ: http://mozilla.org/docs/web-developer/faq.html
Jan 26 '07 #14

P: n/a
于 Fri, 26 Jan 2007 12:22:36 +0200,Henri Sivonen写到:
In article <Lc******************@reader1.news.saunalahti.fi >,
"Jukka K. Korpela" <jk******@cs.tut.fiwrote:
I knew browser is expected to not to actually USE doctype
declaration, but does IE often do things you expected?

Actually browsers _are_ more or less expected to use it in XML context

Well, that wasn't the expectation of the writers of the XML spec:
http://www.xml.com/axml/notes/WhyOptExtEnt.html
ooops, then again IE is not doing things the expected way. I have
experimented that it is true IE will not start displaying the first line
of HTML unless all the .ent files are rechieved (3 of them in total).
Especailly the browser already downloaded the whole xml file and knows NO
ENTITY is used in it at all. (consider they are Chinese text that don't
need any kind of entity and all links in <a href".."are static
webpage links).
Jan 26 '07 #15

P: n/a
VK
On Jan 23, 7:49 pm, Zhang Weiwu <zhangwe...@realss.comwrote:
Now I know I should not use XHTML but it's too late already. I am already
warned only "advanced user" will be able to use xhtml, but I *thought* I
am an advanced user (4 year Linux user and 3 year apache admin). Now I
think the trouble doesn't worth... I should have used HTML!
It is not really a question of how advanced anyone is. One browser
currently taking 85%-95% of the market share (by locations) doesn't
know of application/xhtml+xml content type. This way your task is as
"easy" as say to force remotely some browser to act in a special way
on Content-Type application/octet-stream - say display hex codes on
the screen instead of prompting for download.

In my _private_ opinion XHTML is an obsolete technology to forget and
to move on. Yes, the thing is that it got outdated without even ever
being in any wide use. Just the concept appeared not needed and not
interesting to anyone. In this aspect the decision do not add XHTML on
IE7 was some E.L.E. on "splendid XHTML evolution". It was merely the
final conclusion on a pretty much clear picture.

W3C may still save the rest of the face by adopting HTML 5 - and by
dropping any future attempts to obsolete something on the Web by
purely administrative means. W3C tried it several times already and
each time got obsoleted itself instead. Well, some things are getting
over a hard learning I guess...

Jan 27 '07 #16

This discussion thread is closed

Replies have been disabled for this discussion.