php - 文档类型错误

标签 php xml xslt

<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
    <!DOCTYPE HTML>
    <html>
    <head>

    </head>
    <body>

    </body>
    </html>
</xsl:template>

</xsl:stylesheet>

它在 DOCTYPE 中出现解析错误。如何解决?

最佳答案

W3C HTML 5 Reference建议使用 doctype-system="about:legacy-compat":

For compatibility with legacy producers of HTML — that is, software that outputs HTML documents — an alternative DOCTYPE is available for use by systems that are unable to output the DOCTYPE given above. This limitation occurs in software that expects a DOCTYPE to include either a PUBLIC or SYSTEM identifier, and is unable to omit them. The canonical form of this DOCTYPE is as follows:

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

您可以通过以下任何 XSLT 处理器实现此目的:

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

它将生成:

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

关于php - 文档类型错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12128031/

相关文章:

php - 标签和 MySQL - 速度和可用性

php - 批量 INSERT foreach 语句

java - 如何将命令添加到 Ant 构建 xml

ruby-on-rails - Rails 使用正在运行的构建器编写 xml

xml - 如何删除 XSLT 中的特定子元素?

xslt - for-each 的每次迭代都会增加 XSL 谓词

javascript - 从元素中删除类方法

java - 从 XML 文档获取节点

xslt - 防止将 xmlns =""属性添加到 XSLT 1.0 生成的 HTML 元素中

javascript - 根据下拉菜单中的项目选择在文本框中显示价格