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

Determine the position of an element relative to its

Subject: Determine the position of an element relative to its sibling
From: "Ross, Douglas" <DRoss@xxxxxxxxxx>
Date: Tue, 1 Mar 2005 15:38:21 -0500
prototype element position
I want to use the position of an element ralative to its siblings to
construct an xpath to another element.

For example,

Input:
<TABLE>
	<THEAD>
		<TR>
			<TD>Header Col 1<A class="sort">Sort</A></TD>
			<TD>Header Col 2<A class="sort">Sort</A></TD>
		</TR>
	</THEAD>
	<TBODY>
		<TR>
			<TD id="column1">Col 1 Prototype</TD>
			<TD id="column2">Col 2 Prototype</TD>
		</TR>
	</TBODY>
</TABLE>

Template:
<xsl:template match="A[@class='sort']">
	<A>
		<xsl:attribute name="url">
			base?field=<xsl:value-of
select="ancestor::TABLE/TBODY/TR/TD[<what goes here?>]/@id"/>
		</xsl:attribute>
	</A>
</xsl:template>

Output:
<TABLE>
	<THEAD>
		<TR>
			<TD>Header 1<A url="base?field=column1"
class="sort">Sort</A></TD>
			<TD>Header 2<A url="base?field=column2"
class="sort">Sort</A></TD>
		</TR>
	</THEAD>
	<TBODY>
		<TR>
			<TD id="column1">Col 1 Prototype</TD>
			<TD id="column2">Col 2 Prototype</TD>
		</TR>
	</TBODY>
</TABLE>

Things I have tried in <what goes here?>:

position()

for $i in ../TD return if (generate-id(../TD[$i]) = generate-id(..))
then $i else 0

And various other things to no avail. I'm sure there is an easy way to
do this but searching for position and element adnosium finds thousands
of hits. My eyeballs are crosseyed from reading so many wonderful list
entries about stuff that I'm sure will help me in the long run but are
not solving my immediate problem.

Thanks for any advice, hints, etc.

Douglas Ross
Developer, HTML UI Framework
Kronos
E-mail: dross@xxxxxxxxxx
www.kronos.com

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.