|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Can I access the children by their Index?
-----Original Message----- From: Daniel Newman [mailto:daniel.newman@xxxxxxxxxxx] What I want to do is set up a loop (from 1 to 9), and then be able to access parts of nodes that correspond to this loop. I don't remember who posted this, but it should work: <!-- 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> One side point: David Carlisle reminds: <xsl:param name="start-val" select="'0'"/> ^ ^ you are relying on the implicit coercion from string to number here, simpler to give the number directly <xsl:param name="start-val" select="0"/> Anyways, that should get you started. Edmund XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








