In XSLT 1.0 I'd use FXSL's transform-and-sum template.
--
Cheers,
Dimitre Novatchev
---------------------------------------
Truly great madness cannot be achieved without significant intelligence.
On 6/26/06, Pankaj Bishnoi <pankaj(_dot_)bishnoi(_at_)adeptia(_dot_)com> wrote:
----- Original Message -----
From: "Pankaj Bishnoi" <pankaj(_dot_)bishnoi(_at_)adeptia(_dot_)com>
To: <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
Sent: Monday, June 26, 2006 9:10 PM
Subject: problem with 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><xsl:value-of select="$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
>
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--