xsl-list
[Top] [All Lists]

RE: simple conditional looping

2004-08-16 03:23:03

Hello,

Mukul, Chris and Andrew thank you very much for prompt help. I implemented recursive template and it works fine.

Andrew, I am using msxsl processor, is there any work-around for it similar to Saxon?
p.s. portability is important.

Thanks & Regards,
Keyur


From: "Andrew Welch" <ajwelch(_at_)piper-group(_dot_)com>
Reply-To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
To: <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
Subject: RE: [xsl] simple conditional looping
Date: Mon, 16 Aug 2004 10:40:55 +0100


> Hi Keyur,
>   You can simulate a loop with recursion..
>
> <xsl:call-template name="iterate">
>   <xsl:with-param name="x" select="50" />
> </xsl:call-template>
>
> <xsl:template name="iterate">
>   <xsl:param name="x"/>
>
>   <xsl:if test="$x > 0">
>     <tr/>
>     <xsl:call-template name="iterate">
>       <xsl:with-param name="x" select="$x - 1" />
>     </xsl:call-template>
>   </xsl:if>
> </xsl:template>


Using xslt 2.0 you can use:

  <xsl:for-each select="for $x in 1 to 50 return $x">
    <xsl:value-of select="."/>
  </xsl:for-each>

Using Saxon you can easily use this with your xslt 1.0 stylesheets
(unless you are worried about portability).


Cheers
andrew

--+------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--+--





<Prev in Thread] Current Thread [Next in Thread>