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

AW: how to get position of node in node-set

Subject: AW: how to get position of node in node-set
From: "Kloeck, Erwin" <Erwin.Kloeck@xxxxxx>
Date: Thu, 11 Sep 2003 18:55:11 +0200
xpath get position of node
Thanks again David,

I went for the xsl solution and it works beautifully.

Erwin

-----Ursprüngliche Nachricht-----
Von: David Carlisle [mailto:davidc@xxxxxxxxx]
Gesendet: Donnerstag, 11. September 2003 18:33
An: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Betreff: Re:  how to get position of node in node-set



Node sets are sets and so don't have an intrinsic order.
So nodes don't really have a position in a set (you can't for example
sort the nodes and save the sorted list in a set)
You can ask what is the position if the nodes in the set were sorted
into document order, although actually it's not so easy.
If the nodes are siblings and you are on <entry text="ccc"/>
then you want 
count(preceding-sibling::entry)+1
however you only want to count nodes that are in $legend
so that would be
count(preceding-sibling::entry[@text=$legend])+1
if your text attribute uniquely determines the node, or something like
count(preceding-sibling::entry[count(.|$legend)=count($legend)]+1
otherwise.

They are all pure xpath solutions, or you could use xsl, as in

<xsl:for-each select="$legend">
<xsl:if test="@text='ccc'"><xsl:value-of select="position()"/></xsl:if>

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


 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.