Re: [xsl] counting loop in xslt

Subject: Re: [xsl] counting loop in xslt
From: Mike Brown <mike@xxxxxxxx>
Date: Tue, 28 May 2002 04:22:59 -0600 (MDT)
Pfitzner, Jan wrote:
> is there a possibility to implement a counting loop without using an extension in xslt??

You may realize this already, but in case you didn't... incrementing a counter
is a procedural programming solution, while XSLT is a functional language.
Sometimes you do have to resort to using recursion or an extension, but often
there is a way to achieve the results you want without resorting to using a
counter at all, let alone incrementing it. The most common problems are solved
using careful selection of nodes using the select attribute on an xsl:for-each
or xsl:apply-templates, and utilizing position() when processing those nodes.  

Perhaps if you explained the problem in terms of the input you've got and the
output you want, we could suggest another approach that would be more elegant
and efficient, and that would allow you to add functional programming to your
resume. :)

Or not. Like I said, not all problems can be solved this way. It's just such a 
FAQ that we usually as "why do you think you need a counter?" before we tell 
you how to simulate one :)

   - Mike
____________________________________________________________________________
  mike j. brown                   |  xml/xslt: http://skew.org/xml/
  denver/boulder, colorado, usa   |  resume: http://skew.org/~mike/resume/

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


Current Thread