RE: [xsl] !!!counters in XSL!!!

Subject: RE: [xsl] !!!counters in XSL!!!
From: "Ignacio J. Ortega" <nacho@xxxxxxxx>
Date: Thu, 5 Apr 2001 11:36:25 +0200
> can anyone please tell me whether you can have counters in 
> XSL? I mean I
> want to increment a variable each time I go into a certain 
> for-each loop.

Hola a todos, Rosa:

Some time ago i've developed a way to do simple interations with no
recursivity, only valid for short numbers of iterations  useful for  i.e

This can be easily modified to do a bunch of other things..

You can use a external generated document for big interations, but it's
not very performant, i think, 2 parses...

Perhaps somebody finds that useful..( at least it's usefull for me :)

My 0.02 ? ( nothing compared to the income i've got from the xsl-list :)

Saludos ,
Ignacio J. Ortega

PS.:( this adapted from my code, i've not tested it , sorry if it
contains any errors )

<xsl:stylesheet version="1.0" 
<xsl:output method="text" indent="no" encoding="ISO-8859-1" />
  <!-- data for the transform -->
  <!-- adding d:item elemnts varies the counter -->
  <!-- you can use the index value for something -->
  <xsl:template match="/">
    <xsl:variable name="backptr" select="."/>
    <xsl:for-each select="document('')//d:counter/d:item">
        <!--- Output some elements or do some iterative work -->
        <!-- use backptr for the original context tree       -->
        <!-- the example copies the source tree 4 times to the output
tree -->
        <originaltree copy="{.}">
            <xsl:copy-of select="$backptr"/>

 XSL-List info and archive:

Current Thread