[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

<root>
  <data>
    <item>1</item>
    <item>2</item>
    <item>3</item>
  </data>
</root>

and the stylesheet is

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

<xsl:output method="text"/>

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

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

</xsl:stylesheet>

then Saxon (tested with 9.2.0.5) 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

1

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
	http://msmvps.com/blogs/martin_honnen/

Current Thread