Re: [xsl] for-each question

Subject: Re: [xsl] for-each question
From: Mike Brown <mike@xxxxxxxx>
Date: Fri, 16 Feb 2001 08:54:45 -0700 (MST)
Alec Cove wrote:
> Is there a way to specify how xsl:for-each iterates?
>  For example to have it loop by two in the style of:
> for (int i  =  0; i  < 20; i += 2)

You can't increment an arbitrary counter, but if you want to iterate over
every 2nd node in a set:

<xsl:for-each select="/xpath/for/some/nodes[position() mod 2 = 1]">

for example. Generally, the problems people want to solve by counting from
0 to n are things that can be solved without using a counter at all. Post
your actual problem if this isn't helpful.

   - Mike
Mike J. Brown, software engineer at            My XML/XSL resources: in Denver, Colorado, USA    

 XSL-List info and archive:

Current Thread