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

Re: custom for-each loop in XSLT

Subject: Re: custom for-each loop in XSLT
From: Gurnandan Kaur <teclioness@xxxxxxxxxxx>
Date: Mon, 3 Sep 2001 15:59:39 +0100 (BST)
xslt for each counter
Hey Guys!!

I found the solution for the problem I stated
earlier:)
Take a look at the following code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" version="1.0"
encoding="UTF-8" indent="yes"/>
<xsl:variable name="rating" select="7" />
<xsl:template match="/">
  <html>
    <head><title></title></head>
    <body>
      <xsl:call-template name="KMFDM">
        <xsl:with-param name="counter" select="1" />
      </xsl:call-template>
    </body>
  </html>
</xsl:template>

<xsl:template name="KMFDM">
  <xsl:param name="counter" />
  <xsl:if test="$counter &lt; $rating">
    <xsl:choose>
      <xsl:when test="$counter = $rating">
        <b>
          <xsl:value-of select="$counter" />
        </b>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="$counter" />
      </xsl:otherwise>
    </xsl:choose>
    <xsl:text> </xsl:text>
    <xsl:call-template name="KMFDM">
      <xsl:with-param name="counter" select="$counter
+ 1" />
    </xsl:call-template>
  </xsl:if>
</xsl:template>
</xsl:stylesheet>

This will give me the desired result. I got this
example from
http://www.dpawson.co.uk/xsl/sect2/recursion.html

Enjoy!!:) 


 --- cutlass <cutlass@xxxxxxxxxxx> wrote: > hello
guru,
> 
> u are thinking in procedural terms, which is being
> reflected in your want to
> create code that 'counts' etc, its easier to make
> something datacentric, of
> course they may be out of your control though.
> 
> a 2 pass solution: why not merge your data.xml with
> aan empty calender.xml
> ( which has 7 empty days ) then display what u
> require, testing for the
> empty condition or u could use the position()
> command and explicity run
> through all 7 positions.
> 
> 
> cheers, jim fuller
> 
> 
> 
> ----- Original Message -----
> From: "Gurnandan Kaur" <teclioness@xxxxxxxxxxx>
> To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
> Sent: Monday, September 03, 2001 2:46 PM
> Subject:  custom for-each loop in XSLT
> 
> 
> > Hi
> >
> > I have a timesheet XML which needs to be
> transformed
> > to using XSLT.
> >
> >  In this xml , data about a employee's timesheet
> > details(maximum of 7 days) are present. In some
> cases
> > it might happen that the employee may fill up
> > timesheet for only 3 days so no empty day nodes
> are
> > retuned in which case, I have to show empty text
> boxes
> > for the remaining days(to add upto 7 days). For
> > showing the data entered by employee I can use
> > for-each in XSLT, but what to do for rest of the
> days,
> > as for-each wont accept a number.Can I specify
> that
> > number in any way, for it display the empty text
> > fields (depending on how many days have not been
> > entered by the user)? How can I achieve this ?
> Help
> > please and a big thanks in advance:)
> >
> > Guru
> >
> >
> >
> >
>
____________________________________________________________
> > Do You Yahoo!?
> > Get your free @yahoo.co.uk address at
> http://mail.yahoo.co.uk
> > or your free @yahoo.ie address at
> http://mail.yahoo.ie
> >
> >  XSL-List info and archive: 
> http://www.mulberrytech.com/xsl/xsl-list
> >
> 
> 
>  XSL-List info and archive: 
> http://www.mulberrytech.com/xsl/xsl-list
>  

____________________________________________________________
Do You Yahoo!?
Get your free @yahoo.co.uk address at http://mail.yahoo.co.uk
or your free @yahoo.ie address at http://mail.yahoo.ie

 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.