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

Re: Count previous-siblings w/same attribute value up

Subject: Re: Count previous-siblings w/same attribute value up to attribute value - 1 possible?
From: Liam R E Quin <liam@xxxxxx>
Date: Mon, 12 Dec 2011 20:58:11 -0500
Re:  Count previous-siblings w/same attribute value up
On Mon, 2011-12-12 at 16:54 -0800, Lou Argyres wrote:
> Is there an XPATH-2 select that can count preceding-siblings up to the
> first preceding @level = $lvl-1?
>  <xsl:variable name="lvl" select="@level"/>

so, you could also say,
  <xsl:variable name="upto"
    select="preceding-sibling::section[@level eq $lvl - 1]" />

The preceding sections you don't want are then
   <xsl:variable name="not-these-ones-please"
    select="($upto | $upto/preceding-sibling::section)" />

and so you now want
    preceding-sibling::section except $not-these-ones-please
which is in fact an XPath 2 expression.

Any (negligible) performance penalty for using variables is
insignificant in most cases compared to the time taken for a human to
understand the resulting expression :-)

There are lots of other ways to solve this question, of course.


Liam Quin - XML Activity Lead, W3C, http://www.w3.org/People/Quin/
Pictures from old books: http://fromoldbooks.org/

Current Thread


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.
First Name
Last Name
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.