[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Walking a xsl:key

Subject: Re: [xsl] Walking a xsl:key
From: "Tony Graham" <tgraham@xxxxxxxxxx>
Date: Fri, 22 Feb 2013 13:15:34 -0000 (GMT)

On Fri, February 22, 2013 10:58 am, Ihe Onwuka wrote:
> I thought I saw somewhere that if you omit the 2nd argument to the key
> function a set of all nodes in the named xsl:key will be returned.
> This is the behaviour I want, is it possible?

It doesn't work as you say.  You can't omit the second argument, and if
you provide an empty sequence as the second argument, XSLT 2.0 [1] says:

   If the second argument is an empty sequence, the result of the
   function will be an empty sequence.

The current XSLT 3.0 WD [2] says you get either the empty sequence or "
the set of nodes having an empty sequence as the value of the key
specifier.", depending on the new xsl:key/@composite value (or its

You can get the effect you want by making a key where the @use value is
always the same, e.g., 'true()', so "key('my-key', true())" gets you all
the nodes matched by the xsl:key.


Tony Graham                                   tgraham@xxxxxxxxxx
Consultant                                 http://www.mentea.net
Mentea       13 Kelly's Bay Beach, Skerries, Co. Dublin, Ireland
 --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --
    XML, XSL-FO and XSLT consulting, training and programming

[1] http://www.w3.org/TR/xslt20/#keys
[2] http://www.w3.org/TR/xslt-30/#func-key

Current Thread