Setting XSL doctype

2019-08-14 21:46发布

问题:

I have an issue viewing an application in IE8+... Specifically, in IE9, when opening developer tools, its seems IE7 Standards is set as Document Mode.. Upon viewing source, i think the issue is with my doctype displaying as:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

Looking at my code, here is how my doctype is set:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [
  <!ENTITY nbsp "&#160;">
]>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html" version="4.01" doctype-public="-//W3C//DTD HTML 4.01//EN" doctype-system="http://www.w3.org/TR/html4/strict.dtd" indent="yes"/>

How can i modify this to <doctype html>

Thanks

UPDATE:

Looking through the code further, within the:

<xsl:template match="/">

section, there is no meta settings.

回答1:

In short, you can't. <!DOCTYPE html> is (deliberately by the HTML5 spec) no valid XML doctype (and no valid SGML, too, which HTML 4 was).

The HTML5 spec dictates this doctype, instead:

<!DOCTYPE html SYSTEM "about:legacy-compat">

You can generate it with this output:

<xsl:output method="xml" doctype-system="about:legacy-compat"/>

However, when the XSLT processor wants to process/validate the system identifier, it will fail. AFAIK, it should work in MSXML.