在做XSLT
时transformation
在浏览器端 Mozilla 正在处理 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
作为纯文本并将其作为第一行放在网页上,而 IE 正确显示输出
下面是重现此问题的 xml 和 xsl
文件名 - testdoctype.xml
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="testxdoctype.xsl"?>
<MainHeader>
<ReportType Label="report type">Test</ReportType>
</MainHeader>
文件名 - testdoctype.xsl
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="ISO-8859-1"/>
<xsl:template match="/">
<xsl:text disable-output-escaping="yes">
<![CDATA[
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
]]>
</xsl:text>
<div id="body">
<h1>REPORTS : <xsl:value-of select="./MainHeader/ReportType"/></h1>
</div>
</xsl:template>
</xsl:stylesheet>
除了服务器端 XSLT 转换之外,还有其他方法可以解决此问题吗?
最佳答案
按照设计使用 XSLT,并使用定义您想要的任何 doctype-public
和/或 doctype-system
指令的 xsl:output
指令。 Mozilla 浏览器中的 XSLT 处理器不支持禁用输出转义,因为它不会序列化转换结果,而是呈现结果树。请参阅常见问题解答https://developer.mozilla.org/en/docs/XSL_Transformations_in_Mozilla_FAQ#Can_I_do_disable-output-escaping.3F .
关于html - mozila 中的 XSLT 转换将 <!DOCTYPE> 标记视为纯文本并显示在网页上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33916013/