 |
| XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

March 29th, 2010, 07:29 AM
|
|
Authorized User
|
|
Join Date: Mar 2010
Posts: 45
Thanks: 6
Thanked 0 Times in 0 Posts
|
|
issue with format
Hi,
i am summing functional total value,
my source xml file contanins
<CF_LEDGER_CURRENCY>EUR</CF_LEDGER_CURRENCY>
<C_FUNCTIONAL_TOTAL>94,32</C_FUNCTIONAL_TOTAL>
in my xsl file i have writen like below for the column "betrag"
<element id="betrag"><xsl:value-of select="sum(key('group', concat(C_VAT_TAX_REG_NUM,C_CUST_NAME,C_TAX_REPORTI NG_NAME))/C_FUNCTIONAL_TOTAL)" /></element><xsl:text>
</xsl:text>
When iam runing the report
iam geting out put like , NaN
<element id="betrag">NaN</element>
as my functional total value is in 99,99 format how can i add these amounts in my XSl and show the out put
Thanks
Anil
|
|

March 29th, 2010, 07:36 AM
|
|
Friend of Wrox
|
|
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
|
|
Is that XSLT 2.0? Then use e.g.
Code:
<xsl:value-of select="sum(key('group', concat(C_VAT_TAX_REG_NUM,C_CUST_NAME,C_TAX_REPORTING_NAME))/C_FUNCTIONAL_TOTAL/translate(., ',', '.'))" />
to convert e.g. 94,32 to 94.32.
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
|
|

March 29th, 2010, 07:39 AM
|
 |
Wrox Author
|
|
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
|
|
You need to convert the numbers to the number format recognized by XSLT (and XML Schema).
In XSLT 2.0 you can do:
Code:
sum(key(.....)/translate(., ',', '.'))
If you're using XSLT 1.0 it's more difficult; to sum over values that are not represented directly in the nodes, but computed from the nodes, you typically need either a recursive scan over the nodes, or a two-pass solution.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
|
|

March 29th, 2010, 08:04 AM
|
|
Authorized User
|
|
Join Date: Mar 2010
Posts: 45
Thanks: 6
Thanked 0 Times in 0 Posts
|
|
Hi iam using Oracle XSLT version 2.0 only
but it is giving below error :
XML-22013: (Error) Error in expression: 'sum(key('group', concat(C_VAT_TAX_REG_NUM,C_CUST_NAME,C_TAX_REPORTI NG_NAME))/C_FUNCTIONAL_TOTAL/translate(., ',', '.'))'.
i mentioned like below,
<element id="betrag"><xsl:value-of select="sum(key('group', concat(C_VAT_TAX_REG_NUM,C_CUST_NAME,C_TAX_REPORTI NG_NAME))/C_FUNCTIONAL_TOTAL/translate(., ',', '.'))" /></element><xsl:text>
</xsl:text>
thanks
Anil
|
|

March 29th, 2010, 08:11 AM
|
|
Friend of Wrox
|
|
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
|
|
I think it is best to use an Oracle forum then where someone is hopefully familiar with the quirks of that XSLT processor.
I think the suggestions made should work with any compliant XSLT 2.0 processor.
You could try whether
Code:
<xsl:value-of select="sum(for $e in key('group', concat(C_VAT_TAX_REG_NUM,C_CUST_NAME,C_TAX_REPORTING_NAME))/C_FUNCTIONAL_TOTAL return translate($e, ',', '.'))" />
works better but I am guessing as to what might or might not be supported by your processor.
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
|
|

March 29th, 2010, 08:20 AM
|
 |
Wrox Author
|
|
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
|
|
I don't think the Oracle XSLT processor is a complete implementation of XSLT 2.0 - Check the oracle documentation for details.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
|
|

April 23rd, 2010, 09:57 AM
|
|
Authorized User
|
|
Join Date: Mar 2010
Posts: 45
Thanks: 6
Thanked 0 Times in 0 Posts
|
|
Hi,
it worked fine for me by using the below syntax
<xsl:value-of select="sum(for $t in current-group()/C_FUNCTIONAL_TOTAL return number(translate($t, ',.', '.')))"/>
Thanks
Anil
|
|
 |