After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 676335 - current() in xsl:key incorrect behaviour
current() in xsl:key incorrect behaviour
Status: RESOLVED FIXED
Product: libxslt
Classification: Platform
Component: general
1.1.26
Other All
: Normal normal
: ---
Assigned To: Daniel Veillard
libxml QA maintainers
Depends on:
Blocks:
 
 
Reported: 2012-05-18 17:08 UTC by auxsoft
Modified: 2013-12-13 13:33 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description auxsoft 2012-05-18 17:08:12 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.