Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
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
 
Old April 1st, 2010, 12:10 PM
Authorized User
 
Join Date: Mar 2010
Posts: 45
Thanks: 6
Thanked 0 Times in 0 Posts
Default 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
 
Old April 1st, 2010, 12:17 PM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

You will need to convert them to a more normal format first.

translate('1.234,34', ',.', '.') = '1234.34'
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
The Following User Says Thank You to samjudson For This Useful Post:
anarleti (April 23rd, 2010)
 
Old April 1st, 2010, 12:40 PM
Authorized User
 
Join Date: Mar 2010
Posts: 45
Thanks: 6
Thanked 0 Times in 0 Posts
Default

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
 
Old April 1st, 2010, 12:50 PM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

A common problem - see the following post for an illustration of some solutions:

Problem with sum function
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
 
Old April 1st, 2010, 12:54 PM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

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
 
Old April 2nd, 2010, 03:49 AM
Authorized User
 
Join Date: Mar 2010
Posts: 45
Thanks: 6
Thanked 0 Times in 0 Posts
Default

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 &amp; 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 &amp; 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 &amp; Meincke GmbH &amp; 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 &amp; 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 &amp; Meincke GmbH &amp; 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
 
Old April 2nd, 2010, 08:39 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

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
 
Old April 2nd, 2010, 09:24 AM
Authorized User
 
Join Date: Mar 2010
Posts: 45
Thanks: 6
Thanked 0 Times in 0 Posts
Default

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
 
Old April 2nd, 2010, 09:26 AM
Authorized User
 
Join Date: Mar 2010
Posts: 45
Thanks: 6
Thanked 0 Times in 0 Posts
Default

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
 
Old April 2nd, 2010, 09:28 AM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

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:
anarleti (April 23rd, 2010)





Similar Threads
Thread Thread Starter Forum Replies Last Post
XSL: Currency symbol Euro elayaraja.s XSLT 2 August 12th, 2008 03:00 AM
XSL Fo: Forcing page numbers ashishb2281 XSLT 0 August 1st, 2008 08:43 AM
adding up 2 numbers in xsl umair.aziz XSLT 3 July 14th, 2006 09:24 AM
regarding adding numbers in xsl umair.aziz XSLT 1 June 24th, 2006 12:12 PM
Splitting numbers in XSL francislang XSLT 2 September 15th, 2004 05:34 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.