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

Problem calling this template

Subject: Problem calling this template
From: Steve <subsume@xxxxxxxxx>
Date: Tue, 18 Jul 2006 11:55:26 -0400
running record template
I am calling the below recursive template Records incorrectly. Could
someone please help me see the problem? Recursion isn't working.

-Steve

XML------------- ($services)

<Records>
      <Record>
              <service>1</service>
              <hours>191.25</hours>
      </Record>
      <Record>
              <service>2</service>
              <hours>532.25</hours>
      </Record>
      <Record>
              <service>3</service>
              <hours>32</hours>
      </Record>
      <Record>
              <service>4</service>
              <hours>2858.5</hours>
      </Record>
      <Record>
              <service>5</service>
              <hours>244.3</hours>
      </Record>
<!--  etc -->
XSL--------------

<xsl:template match="/" >
      <xsl:apply-templates select="$services//Record">
              <xsl:with-param name="leftA" select="1920" />
              <xsl:with-param name="leftB" select="350" />
              <xsl:with-param name="leftC" select="878" />
      </xsl:apply-templates>
</xsl:template>

<!--
***When I replace the above $services//Record with $services/Records
(the parent) all output looks like <out service='x' total='T' A='0'
B='0' C='0' Other='T' />
-->


<xsl:template match="Record"> <!-- running totals of hours already used --> <xsl:param name="used">0</xsl:param> <xsl:param name="usedA">0</xsl:param> <xsl:param name="usedB">0</xsl:param> <xsl:param name="usedC">0</xsl:param> <!-- running totals of quota not used --> <xsl:param name="leftA">0</xsl:param> <xsl:param name="leftB">0</xsl:param> <xsl:param name="leftC">0</xsl:param> <xsl:choose> <!-- Capacity used up, output used and move on --> <xsl:when test="(hours = $used)"> <out service="{service}" Total = "{hours}" A="{$usedA}" partB="{$usedB}" C="{$usedC}" Other="{$used - ($usedA + $usedB + $usedC)}" /> <xsl:apply-templates select="following-sibling::Record[0]"> <xsl:with-param name="leftA" select="$leftA" /> <xsl:with-param name="leftB" select="$leftB" /> <xsl:with-param name="leftC" select="$leftC" /> </xsl:apply-templates> </xsl:when> <xsl:when test="not($leftA = 0)"> <xsl:choose> <xsl:when test="($leftA &gt;= (hours - $used))"> <xsl:apply-templates select="."> <xsl:with-param name="used" select="hours" /> <xsl:with-param name="usedA" select="($usedA + hours - $used)" /> <xsl:with-param name="leftA" select="($leftA - (hours - $used))" /> <xsl:with-param name="leftB" select="$leftB" /> <xsl:with-param name="leftC" select="$leftC" /> </xsl:apply-templates> </xsl:when> <xsl:otherwise> <xsl:apply-templates select="."> <xsl:with-param name="used" select="($used + $leftA)" /> <xsl:with-param name="usedA" select="($usedA + $leftA)" /> <xsl:with-param name="leftB" select="$leftB" /> <xsl:with-param name="leftC" select="$leftC" /> </xsl:apply-templates> </xsl:otherwise> </xsl:choose> </xsl:when> <xsl:when test="not($leftB = 0)"> <xsl:choose> <xsl:when test="($leftB &gt;= (hours - $used))"> <xsl:apply-templates select="."> <xsl:with-param name="used" select="hours" /> <xsl:with-param name="usedA" select="$usedA" /> <xsl:with-param name="usedB" select="($usedB + hours - $used)" /> <xsl:with-param name="leftB" select="($leftB - (hours - $used))" /> <xsl:with-param name="leftC" select="$leftC" /> </xsl:apply-templates> </xsl:when> <xsl:otherwise> <xsl:apply-templates select="."> <xsl:with-param name="used" select="($used + $leftB)" /> <xsl:with-param name="usedA" select="$usedA" /> <xsl:with-param name="usedB" select="($usedB + $leftB)" /> <xsl:with-param name="leftC" select="$leftC" /> </xsl:apply-templates> </xsl:otherwise> </xsl:choose> </xsl:when> <xsl:when test="not($leftC = 0)"> <xsl:choose> <xsl:when test="($leftC &gt;= (hours - $used))"> <xsl:apply-templates select="."> <xsl:with-param name="used" select="hours" /> <xsl:with-param name="usedA" select="$usedA" /> <xsl:with-param name="usedB" select="$usedB" /> <xsl:with-param name="leftB" select="($leftB - (hours - $used))" /> <xsl:with-param name="usedC" elect="($usedC + hours - $used)" /> <xsl:with-param name="leftC" select="($leftC -(hours - $used))" /> </xsl:apply-templates> </xsl:when> <xsl:otherwise> <xsl:apply-templates select="."> <xsl:with-param name="usedA" select="$usedA" /> <xsl:with-param name="usedB" select="$usedB" /> <xsl:with-param name="used" select="($used + leftB)" /> <xsl:with-param name="usedC" select="($usedC + $leftC)" /> </xsl:apply-templates> </xsl:otherwise> </xsl:choose> </xsl:when> <xsl:otherwise> <xsl:apply-templates select="."> <xsl:with-param name="used" select="hours" /> <xsl:with-param name="usedA" select="$usedA" /> <xsl:with-param name="usedB" select="$usedB" /> <xsl:with-param name="usedC" select="$usedC" /> </xsl:apply-templates> </xsl:otherwise> </xsl:choose> </xsl:template>

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.