Subject: [xsl] Re: for-loop in xslt problem From: "Dimitre Novatchev" <dnovatchev@xxxxxxxxx> Date: Sat, 5 Apr 2003 17:44:33 +0200 |
Using FXSL one would write: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:myPrint="f:myPrint" > <xsl:import href="iter.xsl"/> <xsl:output method="text"/> <xsl:template match="/"> <xsl:variable name="vfPrint" select="document('')/*/myPrint:*[1]"/> <xsl:variable name="vrtfIterResult"> <xsl:call-template name="scanIter"> <xsl:with-param name="arg1" select="ceiling(/*/total div /*/skip)"/> <xsl:with-param name="arg2" select="$vfPrint"/> </xsl:call-template> </xsl:variable> <xsl:value-of select="$vrtfIterResult"/> </xsl:template> <myPrint:myPrint/> <xsl:template match="myPrint:*"> Print this! </xsl:template> </xsl:stylesheet> When this transformation is performed on your source.xml: <t> <total>45</total> <skip>20</skip> </t> the wanted result is produced: Print this! Print this! Print this! ===== Cheers, Dimitre Novatchev. http://fxsl.sourceforge.net/ -- the home of FXSL "Frankie Roberto" <public@xxxxxxxxxxxxxxxxxx> wrote in message news:ILEMJNHHHLEKFFNFNLDMOEFJCHAA.public@xxxxxxxxxxxxxxxxxxxxx > > Hi, > > I'm having problems trying to implement a 'for' loop in xslt - I haven't > seen any syntax so far that can cope with this (and my book doesn't go into > it). > > To explain, my XML looks something like: > > <total>45</total> > <skip>20</skip> > > > The PHP script I am converting would do something like this: > > for ($count = 0; $count<=$total; ($count = $count + $skip)) { > > echo("Print this"); > > } > > ..looping $total/$skip times plus once for the remainder. > > But I can't see any way of doing this in xslt so far... > > Ta. > > Frankie > > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] for-loop in xslt problem, bix_xslt | Thread | [xsl] Limitation of <xsl:result-doc, Kurt Cagle |
Re: [xsl] reference external javasc, Mark Griffin | Date | RE: [xsl] for-loop in xslt problem, cknell |
Month |