Subject: Re: [xsl] problem with sum() function From: "Dimitre Novatchev" <dnovatchev@xxxxxxxxx> Date: Mon, 26 Jun 2006 09:18:52 -0700 |
<Sum>$pankaj</Sum>
-- Cheers, Dimitre Novatchev --------------------------------------- Truly great madness cannot be achieved without significant intelligence.
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] problem with sum() function, Pankaj Bishnoi | Thread | [xsl] Fw: problem with sum() functi, Pankaj Bishnoi |
Re: [xsl] "'tokenize' is not a vali, Steve | Date | [xsl] Fw: problem with sum() functi, Pankaj Bishnoi |
Month |