[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Looping using XSL

Subject: Re: Looping using XSL
From: "Vasu Chakkera" <vasucv@xxxxxxxxxxx>
Date: Wed, 02 Oct 2002 08:29:59 +0000
xsl looping counter

Josh..
Try the following code.
This may help you
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" omit-xml-declaration="yes" indent="yes"/>
<xsl:template match="/">
<xsl:call-template name="mood">
<xsl:with-param name="max_count" select="'5'"/>
<xsl:with-param name="counter" select="'0'"/>
</xsl:call-template>
</xsl:template>
<xsl:template name="mood">
<xsl:param name="max_count"/>
<xsl:param name="counter"/>
<xsl:if test="$counter &lt; $max_count">
<div class="moodbar"><img src="layout/global/pics/mood-red.gif" alt="" /></div>
<xsl:call-template name="mood">
<xsl:with-param name="counter" select="($counter)+1"/>
<xsl:with-param name="max_count" select="$max_count"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
</xsl:stylesheet>


Cheers
Vasu

From: Josh Campbell <josh@xxxxxxxxxx>
Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx
Subject:  Looping using XSL
Date: Wed, 02 Oct 2002 15:05:29 +1200

I am trying to use a number in an xml file to define the number of times an image gets placed on the page. As the number appears only once and there are no nodes to count or group I'm a little bit stuck.

The XML looks like this:
<mood>
  <rating>5</rating>
</mood>

In this case I want to put five iterations of the image on screen like this:

<div class="moodbar"><img src="layout/global/pics/mood-red.gif" alt="" /></div>
<div class="moodbar"><img src="layout/global/pics/mood-red.gif" alt="" /></div>
<div class="moodbar"><img src="layout/global/pics/mood-red.gif" alt="" /></div>
<div class="moodbar"><img src="layout/global/pics/mood-red.gif" alt="" /></div>
<div class="moodbar"><img src="layout/global/pics/mood-red.gif" alt="" /></div>


Is there a way of doing this so if the number is changed (with a max of 17 possible) the number of images will change?

Thanks in advance.
Josh



XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list




_________________________________________________________________
Join the world?s largest e-mail service with MSN Hotmail. http://www.hotmail.com



XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.