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

Re: finding the position of a node within a node set

Subject: Re: finding the position of a node within a node set
From: Wolfhart Totschnig <wolfhart@xxxxxxxxxxxxx>
Date: Sun, 26 Aug 2012 04:34:16 -0500
Re:  finding the position of a node within a node set
Thank you, Ihe and Michael! The index-of function is what I was looking for.
Wolfhart


On 8/26/12 3:19 AM, Michael Kay wrote:

On 26/08/2012 09:07, Michael Kay wrote:

On 26/08/2012 07:49, Ihe Onwuka wrote:
Assuming Xpath 2.0 take a look at the index-of function.



No, index-of() is no use because it compares nodes by value rather than by identity.


I overlooked that what you are trying to do is to get the position of the node with a given @id value, rather than a node whose identity is known ($node).

In XPath 2.0, if every node has an @id attribute, and if the nodes are in document order, you could use

index-of($nodes/@id, 'foo')

If some nodes have no id attribute, or if you want to avoid sorting the nodes into document order, you could vary this to

index-of($nodes/string(@id), 'foo')

Michael Kay
Saxonica

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.