XSLT无法使用xs:output添加DOCTYPE

r12*_*34x 5 html xslt doctype stylesheet exist-db

我正在使用XSLT来创建HTML输出页面.我需要在输出页面添加一个doctype.我用谷歌搜索,这似乎能够让它工作:

<xsl:output 
  doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
  doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
/>
Run Code Online (Sandbox Code Playgroud)

所以我将它添加到测试转换文件transform.xsl中:

<?xml version="1.0" encoding="ISO-8859-1"?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

<xsl:output 
  doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
  doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
/>

<xsl:template match="/">

<html>
<head>
    <title>test</title>
</head>
<body>
content!
</body>
</html> 

</xsl:template>
</xsl:stylesheet>
Run Code Online (Sandbox Code Playgroud)

但输出HTML不包含doctype .... 其余的例子......很好.

我做错了什么,为什么不添加doctype?

谢谢!

编辑:问题解决了,我正在使用eXist,似乎xsl:output指令不起作用,解决方案:邮件列表

Mic*_*Kay 1

我能想到两个可能的答案

(a) 您的 XSLT 处理器不符合规范,或者

(b) 您的 XSLT 处理器没有执行结果树的序列化,而是执行其他操作。如果序列化是由 XSLT 处理器以外的其他程序完成的(例如,如果您将输出发送到 DOM,然后使用 DOM 序列化程序),则 XSLT 序列化属性将被忽略。