You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Adenilson Roberto Carvalho <ca...@cnptia.embrapa.br> on 2001/02/01 13:11:14 UTC

LOOP

Hi people,

Can anyone please tell me how I can do the following loop in XSL:

 for (i=0;i<n; i++)  {
      writemsg(msg);
                             }
I've tried too many ways to solve this but I can't find a good
solution...


Thanks


Adenilson





Re: LOOP

Posted by Adenilson Roberto Carvalho <ca...@cnptia.embrapa.br>.
Thanks

I 'm gonna try this and for next time I'll post to XSL-List...


Adenilson


Matthew Cordes wrote:

> I'm not sure i understand, but if you want to loop from 1 to n
> here is a way to do it:
>
> <xsl:call-template name="looper">
>         <xsl:with-param name="iterations" select="'5'"/>
> </xsl:call-template>
>
> <xsl:template name="looper">
>         <xsl:param name="iterations"/>
>
>         <xsl:if test="$iterations &gt; 0">
>                 <!-- This is the body of your for loop-->
>                 <!-- do something here -->
>
>                 <!-- recursive call -->
>                 <xsl:call-template name="looper">
>                         <xsl:with-param name="iterations" select="$iterations - 1"/>
>                 </xsl:call-template>
>         </xsl:if>
> </xsl:template>
>
> btw - this should be posted on the mulberrytech list and something
> like it is definitely in their faq.
>
> If you have more xslt questions and cannot solve them using either
> resource feel free to email me off this list.
>
> -matt
>
> On Thu, Feb 01, 2001 at 10:11:14AM -0200, Adenilson Roberto Carvalho wrote:
> > Hi people,
> >
> > Can anyone please tell me how I can do the following loop in XSL:
> >
> >  for (i=0;i<n; i++)  {
> >       writemsg(msg);
> >                              }
> > I've tried too many ways to solve this but I can't find a good
> > solution...
> >
> >
> > Thanks
> >
> >
> > Adenilson
> >
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > Please check that your question has not already been answered in the
> > FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
> >
> > To unsubscribe, e-mail: <co...@xml.apache.org>
> > For additional commands, e-mail: <co...@xml.apache.org>
> >
>
> ---------------------------------------------------------------------
> Please check that your question has not already been answered in the
> FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
>
> To unsubscribe, e-mail: <co...@xml.apache.org>
> For additional commands, e-mail: <co...@xml.apache.org>


Re: LOOP

Posted by Matthew Cordes <mc...@maine.edu>.
I'm not sure i understand, but if you want to loop from 1 to n 
here is a way to do it:

<xsl:call-template name="looper">
	<xsl:with-param name="iterations" select="'5'"/>
</xsl:call-template>	

<xsl:template name="looper">
	<xsl:param name="iterations"/>

	<xsl:if test="$iterations &gt; 0">
		<!-- This is the body of your for loop-->
		<!-- do something here -->

		<!-- recursive call -->
		<xsl:call-template name="looper">
			<xsl:with-param name="iterations" select="$iterations - 1"/>
		</xsl:call-template>	
	</xsl:if>
</xsl:template>

btw - this should be posted on the mulberrytech list and something
like it is definitely in their faq.

If you have more xslt questions and cannot solve them using either 
resource feel free to email me off this list.

-matt


On Thu, Feb 01, 2001 at 10:11:14AM -0200, Adenilson Roberto Carvalho wrote:
> Hi people,
> 
> Can anyone please tell me how I can do the following loop in XSL:
> 
>  for (i=0;i<n; i++)  {
>       writemsg(msg);
>                              }
> I've tried too many ways to solve this but I can't find a good
> solution...
> 
> 
> Thanks
> 
> 
> Adenilson
> 
> 
> 
> 
> 
> ---------------------------------------------------------------------
> Please check that your question has not already been answered in the
> FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
> 
> To unsubscribe, e-mail: <co...@xml.apache.org>
> For additional commands, e-mail: <co...@xml.apache.org>
> 

Re: LOOP

Posted by "Piroumian, Konstantin" <KP...@flagship.ru>.
It's an off-topic XSL question. You'd better ask in XSLT mail list.

I can give you an example how it can be done with named templates and
recursion.
You cannot change the variable value in XSLT, so you must use recursion.

Konstantin.

> Hi people,
>
> Can anyone please tell me how I can do the following loop in XSL:
>
>  for (i=0;i<n; i++)  {
>       writemsg(msg);
>                              }
> I've tried too many ways to solve this but I can't find a good
> solution...
>
>
> Thanks
>
>
> Adenilson
>
>
>
>
>
> ---------------------------------------------------------------------
> Please check that your question has not already been answered in the
> FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
>
> To unsubscribe, e-mail: <co...@xml.apache.org>
> For additional commands, e-mail: <co...@xml.apache.org>
>