Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old December 20th, 2006, 03:18 AM
Registered User
 
Join Date: Jun 2006
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default Formating xpath function result number

Hi,

Is there any way to format the xpath function result number?

example:

xml
-------------------------------------------------
<root>
  <Prod name="a" cost="29152485" />
  <Prod name="b" cost="32036758" />
  <Prod name="c" cost="32273716" />
  <Prod name="d" cost="27425586" />
  <Prod name="e" cost="58829979" />
  <Prod name="f" cost="24354292" />
</root>



xslt
-------------------------------------------------------------------
<xsl:stylesheet version="2.0"
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
    <html>
    <body>
      <table border="1">
      <tr>
        <td><xsl:value-of select="sum(root/Prod/@cost)"/></td>
      </tr>
      </table>
    </body>
    </html>
</xsl:template>
</xsl:stylesheet>




The result of the sum function is: 204072816. In the xslt result I can see the result, but I don't like the format:2.04072816E8.

1. is there any way that the result format will be 204072816?
1. is there any way that the result format will be 204,072,816?

Roni.

(using xslt ver 2.0 with saxon)
Reply With Quote
  #2 (permalink)  
Old December 20th, 2006, 03:27 AM
joefawcett's Avatar
Wrox Author
Points: 9,759, Level: 42
Points: 9,759, Level: 42 Points: 9,759, Level: 42 Points: 9,759, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,073
Thanks: 1
Thanked 38 Times in 37 Posts
Default

I think you can use format-number with a format string of #,##0

--

Joe (Microsoft MVP - XML)
Reply With Quote
  #3 (permalink)  
Old December 20th, 2006, 04:02 AM
Registered User
 
Join Date: Dec 2006
Location: xuzhou, jiangsu, China.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to nicksex Send a message via MSN to nicksex
Default

i don't no ,up,up,up,up,

Reply With Quote
  #4 (permalink)  
Old December 20th, 2006, 04:59 AM
Registered User
 
Join Date: Jun 2006
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanx joefawcett!!!

<xsl:value-of select="format-number(sum(root/Prod/@cost),'#,##0')"/>

this is it.

Reply With Quote
  #5 (permalink)  
Old December 20th, 2006, 08:04 AM
mhkay's Avatar
Wrox Author
Points: 18,225, Level: 58
Points: 18,225, Level: 58 Points: 18,225, Level: 58 Points: 18,225, Level: 58
Activity: 66%
Activity: 66% Activity: 66% Activity: 66%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,924
Thanks: 0
Thanked 281 Times in 276 Posts
Default

Use the XSLT function format-number().



Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with xpath function Phanikumar Biztalk 1 May 22nd, 2008 02:32 AM
ToWords() function not displaying Result kavadoota Crystal Reports 0 November 28th, 2006 01:30 AM
Xpath: sum function gracehanh XSLT 13 September 27th, 2005 09:30 AM
Number formating kondapally Crystal Reports 1 January 3rd, 2005 10:07 AM



All times are GMT -4. The time now is 11:08 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.