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

Add products of two recursive additions

Subject: Add products of two recursive additions
From: "James Steven" <JSteven@xxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 22 Jun 2004 12:16:46 +0100
recursive add
Hello
I have two recursive addition functions producing totals which I would like
to add together.  How can I do this?

Eg To produce the first total I have used the xsl shown below:

<xsl:template match="a">
<xsl:call-template name="orderlist.sum.edit">
<xsl:with-param name="set-of-order" select="b/c"/>
</xsl:call-template>
</xsl:template>

The call-template above calls the template below to display the total for
'data':

<xsl:template name="orderlist.sum.edit">
<xsl:param name="set-of-order"/>
<xsl:variable name="sumorg">
<xsl:call-template name="orderlist.sum">
<xsl:with-param name="set-of-order" select="$set-of-order"/>
</xsl:call-template>
</xsl:variable>
<xsl:value-of select='format-number($sumorg, "£###,###,##0.00")'/>
</xsl:template>

<xsl:template name="orderlist.sum">
<xsl:param name="set-of-order"/>
<xsl:choose>
<xsl:when test="$set-of-order">
<xsl:variable name="first">
<xsl:apply-templates select="$set-of-order[1]/data"/>
</xsl:variable>
<xsl:variable name="rest">
<xsl:call-template name="orderlist.sum">
<xsl:with-param name="set-of-order" select="$set-of-order[position() !=
1]"/>
</xsl:call-template>
</xsl:variable>
<xsl:value-of select="$first + $rest"/>
</xsl:when>
<xsl:otherwise>0</xsl:otherwise>
</xsl:choose>
</xsl:template>

The second total is acquired in the same way.  An example of the xml I am
using is also shown below:

<a>
 <b>
  <c>
    <data>1</data>
  </c>
   <c>
    <data>3</data>
  </c>
  <d>
    <data>1</data>
  </d>
  <d>
   <data>5</data>
  </d>
  <d>
   <data>2</data>
  </d>
 </b>
</a>

The two call-templates above refering to the recursive addition functions
produce the totals for <data> in <c> as 5 and <d> as 7. How do I obtain 12
as the total of both?

Thankyou very much for your help.





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.