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

Re: position of non actual element

Subject: Re: position of non actual element
From: Matt Gushee <mgushee@xxxxxxxxxxxxx>
Date: Wed, 27 Feb 2002 00:02:04 -0700
template for position justification
On Wed, Feb 27, 2002 at 07:35:45AM +0100, Rudolf Pischek wrote:

> I'm having problem with position().
> I need position of node which is not tested now, eg.
> <data>
>   <value attr="first">...</value>
>   <value attr="second">...</value>
> </data>
> 
> <!--xsl:value-of select="position(data/value[@attr = 'second'])"/-->
> of course this cannot run :-))

I don't see a way you could do this with a single XPath expression.
This works with your example, though:

1 <xsl:template match="/">
2   <xsl:apply-templates select="data/value[@attr = 'second']"/>
3 </xsl:template>
4
5 <xsl:template match="value">
6   <xsl:number count="value" from="/data"/>
7 </xsl:template>

Presumably your actual data is more complex than what you are
showing us, so you might need to use a modal template to prevent
outputting the position of every value element:

2   <xsl:apply-templates select="data/value[@attr = 'second']" mode="get-position"/>

5 <xsl:template match="value" mode="get-position">

-- 
Matt Gushee
Englewood, Colorado, USA
mgushee@xxxxxxxxxxxxx
http://www.havenrock.com/

 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.