xsl-list
[Top] [All Lists]

RE: Looping using XSL

2002-10-02 00:08:26
Actually this for each will go through every element in the source
document :) .//* would be every child of the context.

This issue actually should be pretty easy to solve.  I haven't tested
this, but this should work:

<xsl:template match="mood">
   <xsl:param name="iteration" select="number(rating)"/>

   <xsl:if test="$iteration &gt; 0">
      <DoStuff/>
      <xsl:apply-templates select=".">
         <xsl:with-param name="iteration" select="$iteration - 1"/>
      </xsl:apply-templates>
   </xsl:if>
</xsl:template>

HTH!

Dion

-----Original Message-----
From: Josh Campbell [mailto:josh(_at_)zype(_dot_)co(_dot_)nz] 
Sent: Tuesday, October 01, 2002 11:22 PM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: Re: [xsl] Looping using XSL

Vasu Chakkera wrote:

Doesnt <xsl:for-each select="//*[position() &lt;= rating]">
iterate through all the child elements of the context node ., in this 
case "mood"..
so essentially since it has only one child element( "rating" ), It 
should iterate only once irrespective of the condition *[position() 
&lt;= rating]">
so you xsl should produce only one line.
<div class="moodbar"><img src="layout/global/pics/mood-red.gif" alt=""

/></div>
Vasu

That's what I've just found...though I appreciated the idea :-)
Sorry if the words 'looping' and 'iterate' have confused the issue but 
I'm not sure what else to call it.

I guess what's needed is some way of testing against the number in the 
rating node and write out the html line until the rating is equalled.

Josh



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


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



<Prev in Thread] Current Thread [Next in Thread>