[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: counting loop in xslt

Subject: Re: counting loop in xslt
From: Mike Brown <mike@xxxxxxxx>
Date: Tue, 28 May 2002 04:22:59 -0600 (MDT)
xslt loop counter
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.