xslt - XSLT3 是否可以在与 expand-text=yes 相同的模板中使用禁用输出转义?
问题描述
我注意到在 Saxon 的 XSLT3 中尝试使用禁用输出转义时,如果在样式表上甚至在给定的匹配模板上将 expand-text 设置为 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>
生产
<?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>
解决方案
确实这里有一个错误,我已经登录了
https://saxonica.plan.io/issues/4412
xsl:text
范围内的指令在内部expand-text="yes"
实现为与“普通旧”xsl:text
元素不同的表达式,新表达式忽略了支持 doe 的需要。
我在https://github.com/w3c/xslt30-testdisable-output-escaping/doe-0201
的 XSLT 3.0 测试套件中添加了一个测试用例
推荐阅读
- javascript - 如何将一组指令块划分为适合 JavaScript 中特定大小的连续数组的序列?
- sql-server - 将 DATETIME 列中的 NULL 值和空格替换为“不可用”的字符串?
- python - 如何在 pandas 中过滤(使用 loc)时应用数学函数
- php - PHP 数据库的第一行不会包含在网页上的表格中
- python - 如何删除除某些列中存在的某些值之外的所有行?
- mysql - 使一列中的 Date Mon 等于 yyyy-mm-dd hh:mm:ss
- bash - 如何将用于将 docker 注册表连接到 yaml 配置文件的 bash 命令转换?
- facebook - Facebook 令牌更新
- javascript - 如何将“导出默认值”中的数据传递到导出默认值 Vue.js 之外
- java - 用Java画多条线