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

RE: Compute sum of a computed node list

Subject: RE: Compute sum of a computed node list
From: vsubramanian@xxxxxxxxxx
Date: Thu, 6 May 2004 11:45:11 -0400
compute sum of
Thanks Mukul,

This solution worked perfectly to my problem. 
Regards,
Vidya


-----Original Message-----
From: Mukul Gandhi [mailto:mukul_gandhi@xxxxxxxxx]
Sent: Thursday, May 06, 2004 10:10 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE:  Compute sum of a computed node list


Hi Vidya,
Below is the modified stylesheet. It also uses the
nodeset function.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xalan="http://xml.apache.org/xalan"
exclude-result-prefixes="xalan">
<xsl:output method="xml" version="1.0"
encoding="UTF-8" indent="yes"/>

<xsl:decimal-format name="MyFormat"
decimal-separator="." grouping-separator=","/>

<xsl:template match="/">
  <xsl:apply-templates select="abcd_list"/>
</xsl:template>

<xsl:template match="abcd_list">
  <abcd_list>
    <xsl:for-each select="abcd">
      <abcd>
	<xsl:variable name="state_local_salary"
select="state_local_salary"/>
	<xsl:variable name="quarterly_sessions"
select="quarterly_sessions"/>
	<xsl:variable name="non_medicaid_sessions"
select="non_medicaid_sessions"/>
	<xsl:variable name="var_state_local_match"
select="$state_local_salary * ($quarterly_sessions div
($non_medicaid_sessions))"/>
					<state_local_match>
	   <xsl:value-of
select="format-number($var_state_local_match,'###,###.##','MyFormat')"/>
	</state_local_match>
      </abcd>
    </xsl:for-each>
    
    <xsl:variable name="rtf">
       <xsl:for-each select="abcd">
	 <abcd>
	   <xsl:if test="state_local_salary[not(@null)]">
             <xsl:variable name="state_local_salary"
select="state_local_salary"/>
	     <xsl:variable name="quarterly_sessions"
select="quarterly_sessions"/>
	     <xsl:variable name="non_medicaid_sessions"
select="non_medicaid_sessions"/>
	     <xsl:variable name="var_state_local_match"
select="$state_local_salary * ($quarterly_sessions div
($non_medicaid_sessions))"/>
	    <state_local_match>
	       <xsl:value-of
select="$var_state_local_match"/>
	    </state_local_match>
         </xsl:if>
       </abcd>
     </xsl:for-each>
    </xsl:variable>
    
    <state_local_match_total>
	<xsl:value-of
select="format-number(sum(xalan:nodeset($rtf)/abcd/state_local_match),
'###,###.##','MyFormat')"/>
    </state_local_match_total>

</abcd_list>
</xsl:template>

</xsl:stylesheet>

Regards,
Mukul

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.