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

RE: Current node position

Subject: RE: Current node position
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Wed, 11 Jun 2003 21:37:37 +0100
xsl current node position
Your code will work if its called with

<xsl:apply-templates select="date"/>

rather than

<xsl:apply-templates select="*"/>

because position() is the position in the list of nodes selected by the
apply-templates.

I would suggest using last() rather than count(../date), my guess is it
would be more efficient, but that depends on the processor.

Michael Kay

> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx 
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of jwhitney
> Sent: 11 June 2003 19:55
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  Current node position
> 
> 
> Hello,
> 
> I'm trying to generate html code for "Date 1 of 2", "Date 2 
> of 2", etc., from 
> XML as below:
> 
> <a>
>    <b/>
>    <c/>
>    <date>text</date>
>    <date>text again</date>
> </a>
> 
> from within a template that matches "d".  The following 
> stylesheet fragment:
> 
> <xsl:template match="d">
>   <xsl:value-of select="position()" />
>   <xsl:text> of </xsl:text>
>   <xsl:value-of select="count(../date)" />
> </xsl:template>
> 
> produces "3 of 2" and "4 of 2".  Is there a way to restrict 
> position() to 
> evaluate the <date> nodes only?  How else could it be done?
> 
> I'm new to XSLT, obviously.   Thanks in advance for any help 
> with this.
> 
> 
> 
>  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.