[xsl] Re: Looking for an equivalent to recursion within a for loop

Subject: [xsl] 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
"Erika Marlow" <EMarlow@xxxxxxxxxxxxxx> wrote in message
> 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
> 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
> function process-list-conditionally(list L)
> {
>   if (not-empty(L))
> for-each(L)
>   if (true)
> increment-counter
>   otherwise
> counter
> }

What about:



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

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

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.


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

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

Current Thread