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

Re: Preceding-sibling in for-each

Subject: Re: Preceding-sibling in for-each
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Sat, 22 Mar 2003 12:37:33 +0000
preceding sibling xsl for each
Hi Andrew,

> How I can get "preceding-sibling" node in for-each flow:
>
> <xsl:for-each select="//some-node">
>     <xsl:value-of select="*[position()-1]"/>
> </xsl:for-each>
>
> seems not work.

If I interpret you correctly, you can do something like:

  <xsl:variable name="nodes" select="//some-node" />
  <xsl:for-each select="$nodes">
    <xsl:variable name="pos" select="position()" />
    <xsl:value-of select="$nodes[$pos - 1]" />
  </xsl:for-each>

But it's very inefficient and I doubt that it's the best way to
achieve what you want to achieve. If you told us what you're trying to
do (what your source and desired result is) we might be able to show
you a better approach.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.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.