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

problem with sum() function

Subject: problem with sum() function
From: "Pankaj Bishnoi" <pankaj.bishnoi@xxxxxxxxxxx>
Date: Mon, 26 Jun 2006 21:10:59 +0530
java sum function
Hi All
         I am using sum() function with nodelist. Now my problem is that
when a source elemnt contains leading + sign then sum returns NAN. Is there
a way to remove this + sign and then calculate the sum. My source xml is::


<?xml version="1.0" encoding="ISO-8859-1"?>
<Root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<CLIENT_HEADER_RECORD_TYPE-HT><CLIENT_NUMBER><![CDATA[000832]]></CLIENT_NUMB
ER>
</CLIENT_HEADER_RECORD_TYPE-HT>
<EXPERIENCE_SETUP_CHANGE_RECORD_TYPE-ET><CLIENT_NUMBER><![CDATA[000832]]></C
LIENT_NUMBER>
<EXPERIENCE_SETUP_CHANGE_RECORD_TYPE><![CDATA[ET]]></EXPERIENCE_SETUP_CHANGE
_RECORD_TYPE>
<DATA_TYPE><![CDATA[DC]]></DATA_TYPE>
<EXPER_AMT_BY_RESERVE1><![CDATA[+000000000000565500]]></EXPER_AMT_BY_RESERVE
1>
</EXPERIENCE_SETUP_CHANGE_RECORD_TYPE-ET>
<EXPERIENCE_SETUP_CHANGE_RECORD_TYPE-ET><CLIENT_NUMBER><![CDATA[000832]]></C
LIENT_NUMBER>
<EXPERIENCE_SETUP_CHANGE_RECORD_TYPE><![CDATA[ET]]></EXPERIENCE_SETUP_CHANGE
_RECORD_TYPE>
<DATA_TYPE><![CDATA[DC]]></DATA_TYPE>
<EXPER_AMT_BY_RESERVE1><![CDATA[+000000000000505500]]></EXPER_AMT_BY_RESERVE
1>
</EXPERIENCE_SETUP_CHANGE_RECORD_TYPE-ET>
</Root>





My XSL is


<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.1" xmlns:java="http://xml.apache.org/xslt/java"
xmlns:str="http://exslt.org/strings"
xmlns:redirect="org.apache.xalan.xslt.extensions.Redirect"
extension-element-prefixes="redirect">
     <xsl:output method="xml" version="1.0" encoding="ISO-8859-1"
indent="yes"/>

     <xsl:variable name="apos">'</xsl:variable>
     <xsl:template match="/">
          <Root>
               <xsl:apply-templates
select="/Root/CLIENT_HEADER_RECORD_TYPE-HT"
mode="_Root_Record_order1"></xsl:apply-templates>
          </Root>
     </xsl:template>
     <xsl:template match="/Root/CLIENT_HEADER_RECORD_TYPE-HT"
mode="_Root_Record_order1">
          <Record>
   <xsl:variable name="varClientNumber" select="CLIENT_NUMBER"/>
   <xsl:variable name="pankaj" select="sum(following-sibling::
EXPERIENCE_SETUP_CHANGE_RECORD_TYPE-ET[CLIENT_NUMBER=$varClientNumber and
DATA_TYPE='DC']/EXPER_AMT_BY_RESERVE1)"/>
  <Sum>$pankaj</Sum>
          </Record>
     </xsl:template>
</xsl:stylesheet>


and the output is ::



<?xml version="1.0" encoding="UTF-8"?>
<Root xmlns:java="http://xml.apache.org/xslt/java"
xmlns:str="http://exslt.org/strings">
    <Record>
        <Sum>NaN</Sum>
    </Record>
</Root>







I also tried to use XSL temlates with recursion but that fails when we have
large set of data.

Thanks in advance for any help.

Thanks
Pankaj

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.