You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Xalan特定条件下混淆属性与命名空间节点的疑似Bug确认问询

Xalan 1.12.0 中 attribute::node() 误将命名空间节点识别为属性节点的Bug确认

环境信息

  • 系统:Ubuntu 22.04
  • Xalan版本:1.12.0
  • Xerces版本:3.2.3

最小复现示例

test.xml

<root/>

sheet.xsl

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes"/>
<xsl:template match="root"><xsl:value-of select="count(attribute::node())"/></xsl:template>
</xsl:stylesheet>

执行命令

xalan -xsl sheet.xsl -in test.xml

问题现象

预期输出为0(因为<root/>节点没有任何属性节点),但实际输出是1。

进一步验证不同表达式的结果:

  • 替换为name(attribute::node()),输出为xml
  • 替换为attribute::node(),输出为http://www.w3.org/XML/1998/namespace

这说明Xalan错误地将默认的xml命名空间节点当作属性节点返回了。

特殊情况说明

该Bug仅在使用完整的attribute::node()表达式时触发,以下表达式均能正确返回无属性节点的结果:

  • attribute::*
  • @*
  • attribute::xml
  • @xml

结论

这确实是Xalan的一个Bug,违反了XPath 1.0规范——命名空间节点和属性节点属于两类不同的节点,attribute::轴不应包含命名空间节点。

内容的提问来源于stack exchange,提问作者Peter

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.14 05:03:14