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

Subject: Re: [xsl] current() within a key element's @use
From: Chris Maloney <voldrani@xxxxxxxxx>
Date: Fri, 28 Dec 2012 11:38:26 -0500
As for a work-around, the following works with xsltproc, but
interestingly, not with Saxon.  Saxon complains "key() function cannot
be used here".  (This is a variant of the XSLT that Dimitre posted on

    <xsl:stylesheet version="1.0"
      <xsl:output omit-xml-declaration="yes" indent="yes"/>

      <xsl:key name='kTagUsage' match='tagUsage' use='@render'/>
      <xsl:key name="kRendByUsageGi" match="rendition"
        use="key('kTagUsage', @xml:id)/@gi"/>

      <xsl:template match="/">
        <xsl:copy-of select="key('kRendByUsageGi', 'p')/text()"/>
        <xsl:copy-of select="key('kRendByUsageGi', 'emph')/text()"/>

On Fri, Dec 28, 2012 at 10:28 AM, Michael Kay <mike@xxxxxxxxxxxx> wrote:
> On 24/12/2012 00:24, John P. McCaskey wrote:
>> 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?
> Yes, it should. The spec says: "For an outermost expression (an expression not occurring within another expression), the current node is always the same as the context node.".
> The XSLT 1.0 spec is not terribly explicit about what what the current node is in other situations, but the examples it gives lead one to infer that it should be the same as for the outermost containing expression.
> >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? >
> Yes, don't know, and probably not.
> Michael Kay
> Saxonica
>> I need current() to work inside @use, so that I can have an attribute such as
>> use="../tagUsage[@render=current()/@xml:id]/@gi". See If this is a bug, is there a workaround?
>> Thanks for any help.
>> -- JPM
>> John P. McCaskey, mailbox@xxxxxxxxxxxxxxxx

Current Thread