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 December 20th, 2006, 04:18 AM
Registered User
 
Join Date: Jun 2006
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)
 
Old December 20th, 2006, 04:27 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
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)
 
Old December 20th, 2006, 05:02 AM
Registered User
 
Join Date: Dec 2006
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,

 
Old December 20th, 2006, 05:59 AM
Registered User
 
Join Date: Jun 2006
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.

 
Old December 20th, 2006, 09:04 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 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





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 02:30 AM
Xpath: sum function gracehanh XSLT 13 September 27th, 2005 09:30 AM
Number formating kondapally Crystal Reports 1 January 3rd, 2005 11:07 AM





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