This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: for-each question


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: 
webb.net in Denver, Colorado, USA              http://skew.org/xml/



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]