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

RE: Get position of parent

Subject: RE: Get position of parent
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Sat, 17 Jan 2009 16:52:43 -0000
RE:  Get position of parent
It rather depends what you mean by "position", but if you mean the number of
preceding siblings plus one, you can use

count(../preceding-sibling::*)+1

or if you prefer

<xsl:number select=".." count="*"/>

Michael Kay
http://www.saxonica.com/
 

> -----Original Message-----
> From: Philip Vallone [mailto:philip.vallone@xxxxxxxxxxx] 
> Sent: 17 January 2009 13:42
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  Get position of parent
> 
> Hello List,
> 
> What is the best way to get the position of a parent node? In 
> the below xml, assume my context node is para:
> 
> /table/tgroup/tbody/row/entry[1]/para
> 
> If my context node is para, how do I get the position of its 
> parent entry?
> 
> <table frame="all" align="center" id="C-TABLE3" width="90%">
> 	<title>Title</title>
> 	<tgroup cols="3">
> 		<colspec colnum="1" colname="spycolgen1" colwidth="*"/>
> 		<colspec colnum="2" colname="spycolgen2" colwidth="*"/>
> 		<colspec colnum="3" colname="spycolgen3" colwidth="*"/>
> 		<tbody>
> 			<row>
> 				<entry>
> 					<!--get position of 
> parent::entry-->
> 					<para id="table3-para 1">context
> node</para>
> 				</entry>
> 				<entry>
> 					<para>test</para>
> 				</entry>
> 				<entry>
> 					<para>test</para>
> 				</entry>
> 			</row>
> 		</tbody>
> 	</tgroup>
> </table>
> 
> 
> 
> 
> Thanks
> Phil

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.