[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
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 -- Liam Quin - XML Activity Lead, W3C, http://www.w3.org/People/Quin/ Pictures from old books: http://fromoldbooks.org/
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|