[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: for-eaching for specified number of times

Subject: Re: for-eaching for specified number of times
From: "Dimitre Novatchev" <dnovatchev@xxxxxxxxx>
Date: Thu, 22 Jan 2004 06:55:28 +0100
eaching
"Mark Williams" <mark@xxxxxxxxxxx> wrote in message
news:004401c3e057$f6095850$0200a8c0@xxxxxxxxxxx
> Hi,
>
> Is there a way of terminating a for-each loop after it has reached a
> specified number of iterations.

Use the "iter" template from FXSL. You don't need to worry whether you have
some big quantity of nodes.

Here's a small example:

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 xmlns:myMultiplyby3="f:myMultiplyby3"
 exclude-result-prefixes="xsl myMultiplyby3">

 <xsl:import href="itersimple.xsl"/>

 <xsl:output omit-xml-declaration="yes"/>

  <myMultiplyby3:myMultiplyby3/>

  <xsl:template match="/">

   <xsl:variable name="vMultBy3"
select="document('')/*/myMultiplyby3:*[1]"/>

    <xsl:call-template name="iter">
      <xsl:with-param name="pTimes" select="4"/>
      <xsl:with-param name="pFun" select="$vMultBy3"/>
      <xsl:with-param name="pX" select="1"/>
    </xsl:call-template>
  </xsl:template>

  <xsl:template match="myMultiplyby3:*">
    <xsl:param name="arg1"/>

    <xsl:value-of select="3 * $arg1"/>
  </xsl:template>

</xsl:stylesheet>

This (when applied on arbitrary source.xml) will multiply a number (3 in ths
case) 3 times with itself.


Cheers,

Dimitre Novatchev.
FXSL developer

http://fxsl.sourceforge.net/ -- the home of FXSL
Resume: http://fxsl.sf.net/DNovatchev/Resume/Res.html




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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.