 |
| 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
|
|
|
|

April 1st, 2010, 12:10 PM
|
|
Authorized User
|
|
Join Date: Mar 2010
Posts: 45
Thanks: 6
Thanked 0 Times in 0 Posts
|
|
i want to add two euro numbers in my XSL
Hi,
i want to add two numbers in my XSL
my question is how to add the numbers which are in euro currencey ?
ex : 1.234,34 and 32.342,56
o/p - 3357690
Thanks
Anil
|
|

April 1st, 2010, 12:17 PM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
|
|
You will need to convert them to a more normal format first.
translate('1.234,34', ',.', '.') = '1234.34'
|
|
The Following User Says Thank You to samjudson For This Useful Post:
|
|
|

April 1st, 2010, 12:40 PM
|
|
Authorized User
|
|
Join Date: Mar 2010
Posts: 45
Thanks: 6
Thanked 0 Times in 0 Posts
|
|
Hi,
your loguc working fine when iam using only like
translate(C_FUNCTIONAL_TOTAL, ',.', '.')
but i want to show the sum under group so
when i tried like two ways
<xsl:value-of select="sum(current-group()/translate(C_FUNCTIONAL_TOTAL, ',.', '.'))"/>
<xsl:value-of select="sum(current-group()/C_FUNCTIONAL_TOTAL/translate(., ',.', '.'))"/>
but is giving below error :
Error in expression: 'sum(current-group()/translate(C_FUNCTIONAL_TOTAL, ',.', '.'))'.
thanks
Anil
|
|

April 1st, 2010, 12:50 PM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
|
|
A common problem - see the following post for an illustration of some solutions:
Problem with sum function
|
|

April 1st, 2010, 12:54 PM
|
|
Friend of Wrox
|
|
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
|
|
Is that problem occuring with the Oracle XSLT processor? I think in an older thread doing
Code:
<xsl:value-of select="sum(for $t in current-group()/C_FUNCTIONAL_TOTAL return translate($t, ',.', '.'))"/>
was a workaround.
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
|
|

April 2nd, 2010, 03:49 AM
|
|
Authorized User
|
|
Join Date: Mar 2010
Posts: 45
Thanks: 6
Thanked 0 Times in 0 Posts
|
|
Hi,
thanks for the syntax but it worked partially
When i tried in below way
<xsl:value-of select="sum(for $t in current-group()/C_FUNCTIONAL_TOTAL return translate($t, ',.', '.'))"/>
it is giving error XML-23034: (Error) FORG0006: invalid argument type
with the below xml
Code:
<?xml version="1.0"?>
<!-- Generated by Oracle Reports version 10.1.2.0.2 -->
<ZXXEUSL>
<LIST_G_REP_PARAMETER_INFO>
<G_REP_PARAMETER_INFO>
<P_CUSTOM_CHAR8></P_CUSTOM_CHAR8>
</G_REP_PARAMETER_INFO>
</LIST_G_REP_PARAMETER_INFO>
<LIST_G_REP_TRX_DETAIL_INFO>
<G_REP_TRX_DETAIL_INFO>
<C_VAT_TAX_REG_NUM>U22058608</C_VAT_TAX_REG_NUM>
<C_TAX_REPORTING_NAME>0</C_TAX_REPORTING_NAME>
<C_CUST_NAME>CARVATECH KAROSSERIE & KABINENBAU GMBH</C_CUST_NAME>
<C_FUNCTIONAL_TOTAL>,99</C_FUNCTIONAL_TOTAL>
</G_REP_TRX_DETAIL_INFO>
<G_REP_TRX_DETAIL_INFO>
<C_VAT_TAX_REG_NUM>U22058608</C_VAT_TAX_REG_NUM>
<C_TAX_REPORTING_NAME>0</C_TAX_REPORTING_NAME>
<C_CUST_NAME>CARVATECH KAROSSERIE & KABINENBAU GMBH</C_CUST_NAME>
<C_FUNCTIONAL_TOTAL>100,99</C_FUNCTIONAL_TOTAL>
</G_REP_TRX_DETAIL_INFO>
<G_REP_TRX_DETAIL_INFO>
<C_VAT_TAX_REG_NUM>8320012411</C_VAT_TAX_REG_NUM>
<C_TAX_REPORTING_NAME>0</C_TAX_REPORTING_NAME>
<C_CUST_NAME>BODEX BOGUMIL UCINSKI</C_CUST_NAME>
<C_FUNCTIONAL_TOTAL>295,2</C_FUNCTIONAL_TOTAL>
</G_REP_TRX_DETAIL_INFO>
</LIST_G_REP_TRX_DETAIL_INFO>
<CP_REPORTING_LEVEL_NAME></CP_REPORTING_LEVEL_NAME>
<CP_REPORTING_ENTITY_NAME>Hofmeister & Meincke GmbH & Co.KG</CP_REPORTING_ENTITY_NAME>
<CP_NLS_YES>Yes</CP_NLS_YES>
<CP_NLS_NO>No</CP_NLS_NO>
<CP_1></CP_1>
<CS_CURRENCY_CODE>EUR</CS_CURRENCY_CODE>
</ZXXEUSL>
BUT it is working fine with the below xml
Code:
<?xml version="1.0"?>
<!-- Generated by Oracle Reports version 10.1.2.0.2 -->
<ZXXEUSL>
<LIST_G_REP_PARAMETER_INFO>
<G_REP_PARAMETER_INFO>
<P_CUSTOM_CHAR8></P_CUSTOM_CHAR8>
</G_REP_PARAMETER_INFO>
</LIST_G_REP_PARAMETER_INFO>
<LIST_G_REP_TRX_DETAIL_INFO>
<G_REP_TRX_DETAIL_INFO>
<C_VAT_TAX_REG_NUM>U22058608</C_VAT_TAX_REG_NUM>
<C_TAX_REPORTING_NAME>0</C_TAX_REPORTING_NAME>
<C_CUST_NAME>CARVATECH KAROSSERIE & KABINENBAU GMBH</C_CUST_NAME>
<C_FUNCTIONAL_TOTAL>,99</C_FUNCTIONAL_TOTAL>
</G_REP_TRX_DETAIL_INFO>
<G_REP_TRX_DETAIL_INFO>
<C_VAT_TAX_REG_NUM>8320012411</C_VAT_TAX_REG_NUM>
<C_TAX_REPORTING_NAME>0</C_TAX_REPORTING_NAME>
<C_CUST_NAME>BODEX BOGUMIL UCINSKI</C_CUST_NAME>
<C_FUNCTIONAL_TOTAL>295,2</C_FUNCTIONAL_TOTAL>
</G_REP_TRX_DETAIL_INFO>
</LIST_G_REP_TRX_DETAIL_INFO>
<CP_REPORTING_LEVEL_NAME></CP_REPORTING_LEVEL_NAME>
<CP_REPORTING_ENTITY_NAME>Hofmeister & Meincke GmbH & Co.KG</CP_REPORTING_ENTITY_NAME>
<CP_NLS_YES>Yes</CP_NLS_YES>
<CP_NLS_NO>No</CP_NLS_NO>
<CP_1></CP_1>
<CS_CURRENCY_CODE>EUR</CS_CURRENCY_CODE>
</ZXXEUSL>
What i noticed is, it is showing individual records with out any issue but when i am trying to do the sum for grouped records it is throwing error
Thanks
Anil
|
|

April 2nd, 2010, 08:39 AM
|
 |
Wrox Author
|
|
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
|
|
The translate() function returns a string, but sum() is expecting a number. Convert it explicitly:
number(translate(....))
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
|
|

April 2nd, 2010, 09:24 AM
|
|
Authorized User
|
|
Join Date: Mar 2010
Posts: 45
Thanks: 6
Thanked 0 Times in 0 Posts
|
|
Hi,
i tried like below
xsl:value-of select="sum(number(for $t in current-group()/C_FUNCTIONAL_TOTAL return translate($t, ',.', '.')))"/>
but i endup with error
XML-23006: (Error) value does not match required type
Thanks
Anil
|
|

April 2nd, 2010, 09:26 AM
|
|
Authorized User
|
|
Join Date: Mar 2010
Posts: 45
Thanks: 6
Thanked 0 Times in 0 Posts
|
|
Hi,
i think this one is working
<xsl:value-of select="sum(for $t in current-group()/C_FUNCTIONAL_TOTAL return number(translate($t, ',.', '.')))"/>
will update you with the results
thanks
Anil
|
|

April 2nd, 2010, 09:28 AM
|
|
Friend of Wrox
|
|
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
|
|
The suggestion is to call number on the result of translate e.g.
Code:
<xsl:value-of select="sum(for $t in current-group()/C_FUNCTIONAL_TOTAL return number(translate($t, ',.', '.')))"/>
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
|
|
The Following User Says Thank You to Martin Honnen For This Useful Post:
|
|
|
 |