[Home] [By Thread] [By Date] [Recent Entries]
Cool. This is interesting.. You can use recursive templates to get what you
want..
for example fot the xml <?xml version="1.0"?> <example> <total>45</total> <skip>20</skip> </example> If you write XSL along the lines of.. <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <xsl:call-template name="loop"> <xsl:with-param name="maxcount" select="example/total"/> <xsl:with-param name="incriment-factor" select="example/skip"/> <xsl:with-param name="initial-value" select="0"/> </xsl:call-template> </xsl:template> <xsl:template name="loop"> <xsl:param name="maxcount"/> <xsl:param name="incriment-factor"/> <xsl:param name="initial-value"/> <!-- This template produces the following logic for ($count = 0; $count<=$total; ($count = $count + $skip)) { echo("Print this"); } --> <xsl:if test="$initial-value < $maxcount"> <xsl:text>Print this</xsl:text> <xsl:call-template name="loop"> <xsl:with-param name="maxcount" select="$maxcount"/> <xsl:with-param name="initial-value" select="$initial-value+$incriment-factor"/> <xsl:with-param name="incriment-factor" select="$incriment-factor"/> </xsl:call-template> </xsl:if> </xsl:template> </xsl:stylesheet> This produces the result: Print thisPrint thisPrint this Hope this helps. Please run the XSL against the XML i have given first to make sure it works as you wanted. you may then make changes to the xpath to reflect your XML. Please reply back if anything is unclear. HTH Vasu From: Frankie Roberto <public@xxxxxxxxxxxxxxxxxx> Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx To: "Xsl-List@Lists. Mulberrytech. Com" <xsl-list@xxxxxxxxxxxxxxxxxxxxxx> Subject: for-loop in xslt problem Date: Sat, 5 Apr 2003 02:55:43 +0100 _________________________________________________________________ Hotmail messages direct to your mobile phone http://www.msn.co.uk/mobile XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|

Cart



