Subject: Re: [xsl] 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 |
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/
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Count previous-siblings w/sam, Lou Argyres | Thread | Re: [xsl] Count previous-siblings w, G. Ken Holman |
[xsl] Count previous-siblings w/sam, Lou Argyres | Date | Re: [xsl] Count previous-siblings w, G. Ken Holman |
Month |