Re: Re: [xsl] Getting desired node on template match

Subject: Re: Re: [xsl] Getting desired node on template match
From: "alex ek" <alexek@xxxxxxxxxxxxxx>
Date: 12 Sep 2002 12:31:56 -0000
Thanks David
It looked so eazy the way you described that.
You are a genius.
Thanks a lot

On Wed, 11 Sep 2002 David Carlisle wrote :

> and It is working but I did not understand > exactly what it is doing

This is Steve Meunch's devious trick.

To see how it works it helps to lie down in a darkened rule and repeat
the secret XSLT chant until you are in the correct frame of mind. Then
just look at the code again and it all becomes clear.

Basically the problem is that you have a node "." and a set of nodes
returned by the key() function. What you want to know is if the node you
have is teh first element in the set. so..
key('contacts-by-surname', surname)[1]
is the first element (in document order) in the set.
and you want to know if this is the same node as .
you can't do
. = key('contacts-by-surname', surname)[1]
because that will test the string values of the nodes, it does not
test whether the nodes are the same. (So for example all empty elements
would be equal if tested with = as they all have string value "")


the set

(. | key('contacts-by-surname', surname)[1])

is the union of the set set consisting of . and the set consisting of
the first element returned by key(). Either this union has 1 element
or two. If it has two it means the key() function has returned a node
other than the current one.


This message has been checked for all known viruses by Star Internet
delivered through the MessageLabs Virus Scanning Service. For further
information visit or alternatively call
Star Internet for details on the Virus Scanning Service.

XSL-List info and archive:

XSL-List info and archive:

Current Thread