Subject: looping From: Matthew Cordes <mcorde61@xxxxxxxxx> Date: Mon, 27 Nov 2000 10:56:36 -0500 |
>Date: 27 Nov 2000 08:44:35 +0000 >From: Ext.ZXSPRCR2A015@xxxxxxxxxx >Subject: loop? > I dont't know how to loop, from 1 to 10 for example. > With xsl:for-each, I can loop throw elements, but how > to loop throw number? > Laurent Galy > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list <!-- put this in an existing template --> <xsl:call-template name="loop"> <xsl:with-param name="start-val" select="'1'"/> <xsl:with-param name="end-val" select="'10'"/> </xsl:call-template> <!-- loops from $start-val to $end-val with a step value of $increment --> <xsl:template name="loop"> <xsl:param name="start-val" select="'0'"/> <xsl:param name="end-val" select="'0'"/> <xsl:param name="increment" select="'1'"/> <xsl:if test="$start-val <= $end-val"> <!-- do stuff here, i just print out the number --> VALUE: <xsl:value-of select="$start-val"/> <!-- recurse --> <xsl:call-template name="loop"> <xsl:with-param name="start-val" select="$start-val + $increment"/> <xsl:with-param name="increment" select="$increment"/> <xsl:with-param name="end-val" select="$end-val"/> </xsl:call-template> </xsl:if> </xsl:template> </xsl:stylesheet> I know this is much more work than for( int x=1; x <= 10; ++x ), but I think it is the only way to do it in XSL. I'd appreciate anyone's suggestions or alternatives. (As always this is briefly tested and worked for me ( Xalan1.2), your results may vary) -matt XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE : Re: loop?, Ext . ZXSPRCR2A015 | Thread | Re: looping, David Carlisle |
Re: How to test if the current node, Miloslav Nic | Date | RE: doctype, STENZEL |
Month |