[xquery-talk] Getting node position in a for statement

Vallone, Philip Mr CTR USA AMC Philip.Vallone at us.army.mil
Mon Jun 16 11:19:48 PDT 2008

Thank you David. Perfect

-----Original Message-----
From: David Carlisle [mailto:davidc at nag.co.uk] 
Sent: Monday, June 16, 2008 10:14 AM
To: Vallone, Philip Mr CTR USA AMC
Cc: talk at x-query.com
Subject: Re: [xquery-talk] Getting node position in a for statement

> I want to return the position of <tr> within its parent.

well either count that dirctly, using count(1+preceding-sibling::tr) or,
if you wnat to use position() (or at) you need to split it up into two
iterations, one over tables, and one over the rows.

for $table  in //table
for $rows at $p in $table/tbody/tr
	let $cells := count($rows/th)
<row position="{$p} cellcount="{$cells}" >{data($table/title)}</row>


//table/(tbody/tr)/<row position="{position()} cellcount="{count(th)}">


The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.

This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs. 

More information about the talk mailing list