|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: counter in nested for-eachs
This is a FAQ? the answer is that there is no way to modify a variable.
However...
> i have two or three nested for-each elements, is it possible to
> have a global counter for all of them?
>
> i would like that with every loop in every for-each a number
> is incremented by one..
... you can do it like this.
<xsl:for-each select="stuff">
<xsl:variable name="stuffcount" select="count()"/>
<xsl:variable name="stuffpos" select="position() - 1"/>
<xsl:for-each select="more">
<xsl:variable name="morecount" select="count()"/>
<xsl:variable name="morepos" select="position() - 1 + $stuffpos *
$stuffcount"/>
<xsl:for-each select="again">
<xsl:variable name="againpos" select="position() - 1 + $morepos *
$morecount"/>
<xsl:text>Current position: </xsl:text>
<xsl:value-of select="$againpos" />
</xsl:for-each>
</xsl:for-each>
</xsl:for-each>
... but this is, as you can see, very messy.
Cheers,
Dave.
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
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
|

Cart








