Почему моя страница XHTML5 вызывает режим причуд IE? - PullRequest
1 голос
/ 08 августа 2011

Почему моя страница XHTML5 вызывает режим причуд в IE?

Вот тип документа и тому подобное, включая PHP, который отправляет MIME-тип и <?:

<?php header('Content-Type: application/xml;charset=UTF-8'); ?>
<?php echo '<?';?>xml version="1.0" encoding="UTF-8"?>
<?php echo '<?';?>xml-stylesheet type="text/xsl" href="ie-xhtml-fix.xsl"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" dir="ltr">
<head><meta charset="UTF-8" />

Тогда ie-xhtml-fix.xsl от http://www.w3.org/MarkUp/2004/xhtml-faq#ie, это:

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

Извините, я должен спросить.Я не могу понять это, я не могу найти информацию о том, что может быть причиной проблемы.Я надеюсь, что он будет работать в IE7 и выше.

1 Ответ

2 голосов
/ 09 августа 2011

Проблема заключается в том, что ваш шаблон XSLT копирует инструкции обработки в вывод, что означает, что они анализируются IE перед doctype, и это приводит к переходу IE в режим Quirks.

Tryэтот XSLT вместо:

<stylesheet version="1.0"
     xmlns="http://www.w3.org/1999/XSL/Transform">
    <output method="html" version="1.0" encoding="UTF-8" doctype-system="about:legacy-compat" />

    <!-- Copy all the child nodes of the root -->
    <template match="/"> 
        <copy>
           <apply-templates select="node()|@*"/>
         </copy>
    </template>

    <!-- For any other node, just copy everything -->
    <template match="node()|@*"> 
       <copy-of select="."/>
    </template>

    <!-- For processing instructions directly under the root, discard -->
    <template match="/processing-instruction()" />
</stylesheet>

Протестирован и работает в IE6 и выше.

...