Subject: Re: [xsl] Getting desired node on template match From: David Carlisle <davidc@xxxxxxxxx> Date: Wed, 11 Sep 2002 16:09:55 +0100 |
> 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 "") However 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. David _____________________________________________________________________ This message has been checked for all known viruses by Star Internet delivered through the MessageLabs Virus Scanning Service. For further information visit http://www.star.net.uk/stats.asp or alternatively call Star Internet for details on the Virus Scanning Service. XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: Re: [xsl] Getting desired node , alex ek | Thread | Re: [xsl] Getting desired node on t, J.Pietschmann |
Re: [xsl] generalized unique elemen, David Carlisle | Date | RE: [xsl] generalized unique elemen, Michael Kay |
Month |