[xsl] context (size) when evaluating use expression of an xsl:key

Subject: [xsl] context (size) when evaluating use expression of an xsl:key
From: Martin Honnen <Martin.Honnen@xxxxxx>
Date: Fri, 05 Feb 2010 15:50:24 +0100
How is the context defined when evaluating the 'use' attribute of an 'xsl:key' element, in particular what is the context size?

The XSLT specification in http://www.w3.org/TR/xslt20/#key merely says:
"The expression will be evaluated with the node that matches the pattern as the context node."
but it does not say what is the context size.

I get different results from different XSLT processors, if the input XML is


and the stylesheet is


<xsl:output method="text"/>

<xsl:key name="k1" match="item" use="position()"/>

  <xsl:template match="/">
    <xsl:value-of select="key('k1', 1)"/>


then Saxon (tested with and Gestalt output

1 2 3

meaning the context size is 1 each time the 'use' expression has been evaluated but AltovaXML tools and IBM's beta output


meaning the context size is not 1 for these processors.

I suspect Saxon and Gestalt are right but I am having a hard time to find an argument for that in the specification.


	Martin Honnen

Current Thread