You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Lautaro Brasseur <lb...@nuevobancobisel.com.ar> on 2002/12/17 21:34:40 UTC

for loop in XSLT

Somebody knows how to implement a for-like loop in XSLT? I found the following example in XSLT 2.0, but it doesn't work in 1.0:

  <xsl:for-each select="1 to 5">
    <xsl:variable name="x" select="$x+1"/>
  <xsl:for-each>


Re: for loop in XSLT

Posted by Tony Collen <tc...@hist.umn.edu>.
Lautaro Brasseur wrote:

>Somebody knows how to implement a for-like loop in XSLT? I found the following example in XSLT 2.0, but it doesn't work in 1.0:
>
>  <xsl:for-each select="1 to 5">
>    <xsl:variable name="x" select="$x+1"/>
>  <xsl:for-each>
>

Lautaro,

Please ask any XSL-related questions to the Mulberry XSL-List.  It's 
located at http://www.mulberrytech.com/xsl/xsl-list/  

Thanks,
Tony


---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>


Re: for loop in XSLT

Posted by Yves Vindevogel <yv...@implements.be>.
Something like this :

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
xmlns:fo="http://www.w3.org/1999/XSL/Format">
	<xsl:template match="/">
		<p>Test Page</p>
		
		<xsl:call-template name="forloop">
			<xsl:with-param name="counter" select="1"/>
		</xsl:call-template>
	</xsl:template>
	
	<xsl:template name="forloop">
		<xsl:param name="counter"/>
		
		<p><xsl:value-of select="$counter"/></p>
		
		<xsl:if test="$counter &lt; 5">
			<xsl:call-template name="forloop">
				<xsl:with-param name="counter" select="$counter +1"/>
			</xsl:call-template>
		</xsl:if>
	</xsl:template>
</xsl:stylesheet>



> Somebody knows how to implement a for-like loop in XSLT? I found the
> following example in XSLT 2.0, but it doesn't work in 1.0:
>
>   <xsl:for-each select="1 to 5">
>     <xsl:variable name="x" select="$x+1"/>
>   <xsl:for-each>

-- 
Kind regards,
Yves Vindevogel

Implements
Kortrijkstraat 2 bus 1  --  9700 Oudenaarde  --  Belgium
Phone/Fax: +32 (55) 45.74.73  --  Mobile: +32 (478) 80.82.91
Mail: yves.vindevogel@implements.be  --  www.implements.be

Quote: The winner never says participating is more important than winning.

---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <co...@xml.apache.org>
For additional commands, e-mail:   <co...@xml.apache.org>