[xsl] current() within a key element's @use

Subject: [xsl] current() within a key element's @use
From: "John P. McCaskey" <groups@xxxxxxxxxxxxxxxx>
Date: Sun, 23 Dec 2012 19:24:59 -0500
I have found inconsistent behavior when using current() in the use attribute of a key element.

Shouldn't these
    <xsl:key name="keyUsingCurrent"   match="color" use="current()/@id"/>
    <xsl:key name="keyWithoutCurrent" match="color" use="@id"/>
produce the same set of keys?

With this XML
   <t>
      <color id="b">blue</color>
      <color id="r">red</color>
   </t>

and this XSLT

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

<xsl:output method="text" indent="no"/>

    <xsl:key name="keyUsingCurrent"   match="color" use="current()/@id"/>
    <xsl:key name="keyWithoutCurrent" match="color" use="@id"/>

    <xsl:template match="/">
        (1):<xsl:value-of select="key('keyUsingCurrent', 'b')"/>
        (2):<xsl:value-of select="key('keyUsingCurrent', 'r')"/>

        (1):<xsl:value-of select="key('keyWithoutCurrent', 'b')"/>
        (2):<xsl:value-of select="key('keyWithoutCurrent', 'r')"/>
    </xsl:template>

</xsl:stylesheet>

Xalan, Saxon and the XSLT processors in Firefox and Internet Explorer return

        (1):blue
        (2):red

        (1):blue
        (2):red

which I think is correct;

xsltproc and the XSLT processors in Chrome and Safari return

        (1):
        (2):

        (1):blue
        (2):red

which I think is incorrect.

Is my understanding of current() inside @use correct? Am I witnessing a bug in code that xsltproc, Chrome and Safari share? If so, to whom would I report such a bug? Would doing so make any difference?

I need current() to work inside @use, so that I can have an attribute such as
use="../tagUsage[@render=current()/@xml:id]/@gi". See http://stackoverflow.com/questions/13984167/create-xsl-key-by-joining-elements. If this is a bug, is there a workaround?


Thanks for any help.

-- JPM

John P. McCaskey, mailbox@xxxxxxxxxxxxxxxx

Current Thread