GNOME Bugzilla – Bug 676335
current() in xsl:key incorrect behaviour
Last modified: 2013-12-13 13:33:17 UTC
When used in the use attribute in the xsl:key element, the current() function doesn't reference the correct node. A simple example: This xml: <?xml version="1.0"?> <root> <val k="one">hello</val> <val k="two">2</val> </root> when applied this stylesheet: <?xml version='1.0'?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:key name="index" match="val" use="current()/@k" /> <xsl:template match="/"> <xsl:value-of select="key('index','one')" /> </xsl:template> </xsl:stylesheet> The correct output is "hello". xsltproc doesn't give any result. Just removing the current() step in the xpath in xsl:key produces the desired result. Obviously in this simple example the use of current() is superfluous but is a problem when it needs to be used in a predicate. current() should reference the matching node.
Fixed with commit ce5a0dd6: https://git.gnome.org/browse/libxslt/commit/?id=ce5a0dd6a70efdb214aba12fefc6bbf8c201b838