views:

223

answers:

2

I have been searching for a while for a DOCTYPE tag that will make internet explorer standards-compliant for css with a normal xml document, as I want to use the white-space css attribute. This page states that using the "doctype 'XML'" should be enough for internet explorer 6+ to come through - But I have tried every DOCTYPE tag I could think of/ find in examples, without getting the expected results. Maybe I am missing something else here, but basically I think the right DOCTYPE tag (in the right place in the code) should do it.

Here is the code I am testing with:

Test.css:

Message {
   white-space: pre-wrap;
}

Test.xml:

<?xml version="1.0"?>
<?xml-stylesheet href="Test.css" type="text/css"?>
<Message><![CDATA[
Some data

which is   pre   

formatted
]]></Message>

The example above works fine as-is in FF & Safari.

+1  A: 

There is no such thing, because IE does not yet support the correct mime-type, application/xml+xhtml, for serving HTML as XML. IE does, however, support XML directly so you could simply write email directly without it pretended to be HTML and then use a stylesheet to make the page appear as HTML. This method WILL result in accessibility and semantic violations because nobody is going to understand the grammar of your XML elements.

And that is probably why XML is poorly adopted by the web.

A: 

There isn't one, as far as I've found. The docs lie. Stylesheet-rendered raw-XML documents appear always to be in quirks mode, when in theory they should always be in standards mode regardless of doctypes (which are kind of antiquated and not used so much in XML these days anyhow).

The example above doesn't really demonstrate that though... I tested with something like this:

<?xml-stylesheet href="test.css" type="text/css"?>
<potato>
    <custard>X</custard>
</potato>

custard { width: 150px; padding: 50px; background: yellow; }

This renders the total width+padding as 150px instead of the correct 250px. Adding any one of:

<!DOCTYPE potato>
<!DOCTYPE potato SYSTEM "blankfile.dtd">
<!DOCTYPE potato PUBLIC "-//W3C//DTD XHTML 1.0//EN" "blankfile.dtd">

or changing the root element to ‘html’ and referencing the real XHTML DTD URI, makes no difference. Raw XML rendering stays in quirks mode. This is nothing to do with the recognition of the MIME application/xhtml+xml media type.

I guess IE's raw-XML rendering is a feature that hasn't really seen any updates since IE5. It continues to be slow, quirky and useless.

bobince