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 June 20th, 2004, 12:53 PM
Registered User
 
Join Date: Jun 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Change number of significant digits displayed

Hi,

I have a question about formatting Real numbers.. Can I change using XSLT the number of significant digits that appear after being processed?

E.g.
If I have an XML like:

<test>
  <a>1.38543934543454</a>
</test>

I want an output that only shows:
1.3854


And I still want my XML file to contain the full precision.



Thanks,
  Prem
 
Old June 25th, 2004, 11:50 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 150
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I don't know how to avoid rounding. Let me know if you find out!

In your xsl add this line in the top:

<xsl:decimal-format name="num"/>

Then use this:

<xsl:value-of select="format-number(test/a,'#.####', 'num')"/>

I think that's the closest I can get by now!





Similar Threads
Thread Thread Starter Forum Replies Last Post
help me to change number format? haarishr Pro VB 6 4 June 20th, 2008 06:30 AM
Mulitplication of two digits in Datagrid [email protected] Visual Studio 2005 0 June 10th, 2008 03:35 PM
A significant step closer to making TBH modular jimibt BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 0 October 12th, 2007 04:31 AM
Restricting the # of digits after a decimal in a K stevenyoo321 VB How-To 1 April 18th, 2007 07:52 AM
Number of Digits Colonel Angus Javascript How-To 3 December 1st, 2004 09:12 AM





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