简体   繁体   English

XSLT无法使用xs:output添加DOCTYPE

[英]XSLT fails to add DOCTYPE using xs:output

I'm using XSLT to create a HTML output page. 我正在使用XSLT来创建HTML输出页面。 I need to add a doctype to the output page. 我需要在输出页面添加一个doctype。 I googled and this seems to be able to get it working: 我用谷歌搜索,这似乎能够让它工作:

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

So I added it to a test transformation file, transform.xsl: 所以我将它添加到测试转换文件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>

But the output HTML does not contain a doctype... . 但输出HTML不包含doctype .... The rest of the example ... comes out fine. 其余的例子......很好。

What am I doing wrong, why isn't the doctype added? 我做错了什么,为什么不添加doctype?

Thanks! 谢谢!

EDIT: problem solved, I'm using eXist and it seems the xsl:output instruction will not work, the solution: mailing list 编辑:问题解决了,我正在使用eXist,似乎xsl:output指令不起作用,解决方案: 邮件列表

I can think of two possible answers 我可以想到两个可能的答案

(a) your XSLT processor is not conformant with the spec, or (a)您的XSLT处理器不符合规范,或

(b) your XSLT processor is not doing the serialization of the result tree, something else is. (b)您的XSLT处理器没有对结果树进行序列化,而另一些则是。 If the serialization is done by something other than the XSLT processor (eg if you send output to a DOM and then use the DOM serializer) then the XSLT serialization properties will be ignored. 如果序列化是通过XSLT处理器以外的其他方式完成的(例如,如果将输出发送到DOM然后使用DOM序列化程序),则将忽略XSLT序列化属性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM