xsltproc returns nodes in wrong order when using xsl:key

Bug #722343 reported by Christian Assig
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
libxslt (Ubuntu)
New
Undecided
Unassigned

Bug Description

I'm using libxslt and xsltproc 1.1.26-6 in Ubuntu maverick.

When I use xsltproc with the following XML document:

<?xml version="1.0" encoding="utf-8"?>
<root>
  <a>
    <b reference="1"/>
  </a>
  <c id="1" />
</root>

and the following XSLT transformation:

<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:key name="key-test" match="*" use="@id" />
  <xsl:key name="key-test" match="*" use="@reference" />
  <xsl:template match="/">
    <xsl:copy-of select="key('key-test', '1')[1]" />
    <xsl:copy-of select="key('key-test', '1')" />
  </xsl:template>
</xsl:transform>

the output is:
<?xml version="1.0"?>
<c id="1"/><b reference="1"/><c id="1"/>

So in this case, key('key-test', '1')[1] returns a node (c in this case) that is not the first node that is returned when using key('key-test', '1') (this returns b followed by c).

I've tried Saxon 9.3.0.4 and the SAP XSLT Processor, and both returned what I would have expected:
<?xml version="1.0"?>
<b reference="1"/><b reference="1"/><c id="1"/>

I have also noticed that changing the order of the two xsl:key elements in my transformation changes the result of key('key-test', '1')[1] in xsltproc, while key('key-test', '1') stays the same. In both Saxon and the SAP XSLT Processor, the order of the elements does not have any influence on the output.

As both Saxon and the SAP XSLT Processor behave the way I would have expected, and xsltproc does not, I assume there is something wrong with xsltproc.

Edit: XSLT transformation was not indented properly.

Revision history for this message
Christian Assig (chrassig) wrote :

xsltproc 1.1.26-1ubuntu1 in Ubuntu lucid returns the same result as xsltproc in Ubuntu maverick:
<?xml version="1.0"?>
<c id="1"/><b reference="1"/><c id="1"/>

description: updated
description: updated
Revision history for this message
Christian Assig (chrassig) wrote :

libxslt and xsltproc 1.1.26-6build1 in Ubuntu natty also return the unexpected result:
<?xml version="1.0"?>
<c id="1"/><b reference="1"/><c id="1"/>

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.