Col*_*zie 6 xslt saxon xslt-3.0
我注意到在 Saxon 的 XSLT3 中尝试使用禁用输出转义时,如果在样式表或什至在给定的匹配模板上将扩展文本设置为 yes,它将不起作用
以下代码(在其自身上运行时)显示了该问题(在 Saxon 9.8.0.12 中)。我知道这是一个不寻常的组合,并且通常不惜一切代价避免禁用输出转义,而只是试图确定正确的行为。
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0">
<xsl:template match="/">
<out>
<xsl:apply-templates/>
</out>
</xsl:template>
<xsl:template match="xsl:stylesheet" expand-text="true">
<expandtext>
<count>{count(*)}</count>
<xsl:text disable-output-escaping="true"><test/></xsl:text>
</expandtext>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="xsl:template" expand-text="false">
<notexpandtext>
<count>{count(*)}</count>
<xsl:text disable-output-escaping="true"><test/></xsl:text>
</notexpandtext>
</xsl:template>
</xsl:stylesheet>
Run Code Online (Sandbox Code Playgroud)
产生
<?xml version="1.0" encoding="UTF-8"?>
<out>
<expandtext><count>3</count><test/></expandtext>
<notexpandtext><count>{count(*)}</count><test/></notexpandtext>
<notexpandtext><count>{count(*)}</count><test/></notexpandtext>
<notexpandtext><count>{count(*)}</count><test/></notexpandtext>
</out>
Run Code Online (Sandbox Code Playgroud)
确实这里有一个错误,我已经记录了
https://saxonica.plan.io/issues/4412
xsl:text范围内的指令在expand-text="yes"内部实现为与“普通旧”xsl:text元素不同类型的表达式,并且新表达式忽略了支持 doe 的需要。
disable-output-escaping/doe-0201我已在 XSLT 3.0 测试套件中添加了一个测试用例,网址为https://github.com/w3c/xslt30-test