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

Re: Looking for an equivalent to recursion within a fo

Subject: Re: Looking for an equivalent to recursion within a for loop
From: "Dimitre Novatchev" <dnovatchev@xxxxxxxxx>
Date: Sat, 31 May 2003 07:54:28 +0200
iterate through list increment count
"Erika Marlow" <EMarlow@xxxxxxxxxxxxxx> wrote in message
news:E159FD8A01059F4FBA480CF7A6BC403A6E5B3F@xxxxxxxxx
> Dear List Members:
>
> I have run into a situation where I must increment a counter.  This can be
> worked around using recursion and calling a template. However, I need to
> increment the counter while I iterate through a node-set.  This would
> normally just be a matter of adding another parameter to the template
call,
> but I have to increment the counter based on a condition while iterating
> through the node-set.
>
> The pseudo-code for this particular situation would be something like
this:
>
> function process-list-conditionally(list L)
> {
>   if (not-empty(L))
> for-each(L)
>   if (true)
> increment-counter
>   otherwise
> counter
> }


What about:

count($L[yourCondition])

or

<xsl:for-each select="$L[yourCondition]">

  <xsl:variable name="theCounter" select="position()"/>
</xsl:for-each>



If the case is more complicated, one will use one of  "filter" , "foldl" ,
"iter, "scanIter" or  "scanl" templates from FXSL -- I cannot say which,
because I haven't seen your actual problem.



=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL






 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.