Peter
Peter

Reputation: 383

Xalan seems to confuse attribute nodes and namespace nodes under specific conditions

Below is a minimal reproducible example of what appears to be a bug in Xalan (Ubuntu 22.04, Xalan version 1.12.0, Xerces version 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>

The following invocation:

xalan -xsl sheet.xsl -in test.xml

yields 1 instead of expected 0. Changing the select attribute value to name(attribute::node()) and attribute::node() changes the output to xml and http://www.w3.org/XML/1998/namespace respectively, so it looks like Xalan erroneously returns the namespace node as an attribute node. The result is not consistent, though: the bug seems to be triggered only by the full, unabbreviated attribute::node() expression; attribute::*, @*, attribute::xml and @xml correctly return no attribute nodes. I'm in the process of relearning XML, XPath and XSLT after a very long break, so I just want to make sure I'm not misinterpreting something and it's indeed a bug.

Upvotes: 2

Views: 60

Answers (0)

Related Questions