BIP's for-each number loop

Since XSL doesn't have one, Oracle has implemented a for-each number loop which - if you manage to Google it – usually looks like this in the examples:

<xsl:for-each select="xdoxslt:foreach_number($_XDOCTX, 1, 3, 1)">

It's fairly clear from said examples that 3 is the number of times it's going to loop, but the preceding and following 1's are not explained very well (if at all). So let's replace them with some named variables for readability's sake:

<xsl:for-each select="xdoxslt:foreach_number(

Now we see that the first parameter (well, second technically, but let's ignore the mandatory $\_XDOCTX) is the number that it begins looping from, the second is the number it will loop to, and the third is the increment.

Given that $loopFrom = 3, one might expect the position() function on the first loop to return exactly that: 3. However, what you'll get is 1. Always. Irrespectively of what value $loopFrom has.

The solution is as simple as it is obvious: use position() + $loopFrom instead of just position().

results matching ""

    No results matching ""