Subject: [xsl] implement for loop with XSLT From: Tobias Reif <tobiasreif@xxxxxxxxx> Date: Tue, 27 Mar 2001 06:45:07 -0800 (PST) |
Dan Diebolt <dandiebolt@xxxxxxxxx> wrote on http://www.biglist.com/cgi-bin/wilma/wilma_hiliter/xsl-list/200103/msg01009.html : > I came up with the enclosed code to grab the value of > an <n> element > and generate a list of integers and their squares > between 1 and n: > > 1 1 > 2 4 > 3 9 > ... > 8 64 > 9 81 > 10 100 > > I am a bit stunned at how intricate this code looks. > Is there > a more direct way to accomplish this? try <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text" encoding="UTF-8"/> <xsl:template match="/" name="square"> <xsl:param name="range" select="100"/> <xsl:param name="current" select="1"/> <xsl:value-of select="$current"/> * <xsl:value-of select="$current"/> = <xsl:value-of select="$current * $current"/> <xsl:text> </xsl:text> <xsl:if test="$current < $range"> <xsl:call-template name="square"> <xsl:with-param name="current" select="$current+1"/> </xsl:call-template> </xsl:if> </xsl:template> </xsl:stylesheet> Tobi ===== Tobias Reif http://www.pinkjuice.com/myDigitalProfile.htm __________________________________________________ Do You Yahoo!? Get email at your own domain with Yahoo! Mail. http://personal.mail.yahoo.com/?.refer=text XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] implement for loop with X, Goetz Bock | Thread | [xsl] xsl: Changing the order of pr, Madhavi Ganapathiraj |
Re: [xsl] DSSSL->XSLT; problems imp, AKillian | Date | [xsl] webMethods' XML Schema for XS, Asir S Vedamuthu |
Month |