[xsl] key( 'myKey', 'key', $current) searches only the sub tree from $current

Subject: [xsl] key( 'myKey', 'key', $current) searches only the sub tree from $current
From: Johannes Neubauer <johannes.neubauer@xxxxxxxxxxxxxxxxx>
Date: Sat, 23 Feb 2008 17:08:05 +0100
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

I have a <xsl:key> that maps unique attribute values of sibling-elements
to the respective element. When I use the key() function in a
<xsl:function> I have to submit a node as a third argument, so that it's
clear which source document is used (there's no context node in
functions available).

So I tried this:

xsl:key:
<xsl:key match="book" name="myKey" use="@id"/>

function call in XPath:
key('myKey', '100', $current) (: $current is the context node supplied
as a parameter to the xsl:function :)

source doc:
<test>
~  <book id="100"/>
~  <book id="101"/>
~  <book id="102"/>
~  <book id="103"/>
</test>

But I find the respective book element only if it is $current. When I
change the function call to this:
key('myKey', '100', root($current))

I find it independent from which element $current is, it has to be from
the right source document only.

"XSLT 2.0 3rd edition" from Michael Kay page 574 says, that the supplied
~ third argument must not be the document node, but  any node of the
source document.

Is this a bug in Saxon or one of the things that changed in the spec
after publishing the book? I didn't find the part in the online
documentation, where the xslt functions are described.

wfg,
Jonny.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHwETlGaEJacf6i/cRAoQ/AJ4wkJueQNuLmmTSIUM1zAbW4zA0qgCghSI+
KyJW65lEWL2cGFDWxBmdxJ0=
=nnEt
-----END PGP SIGNATURE-----

Current Thread