[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
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