[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Getting desired node on template match

Subject: Re: Getting desired node on template match
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 11 Sep 2002 16:09:55 +0100
Re:  Getting desired node on template match
> 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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.