473,748 Members | 2,502 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XSLT number-format command and scientific notation (HELP!)

Well, the project I am working on has now come to a screeching halt! I
have been developing a program that heavily utilizes ADO.NET record
sets. To generate reports, I convert the recordset to XML, and then
apply an XSLT to transform the XML into HTML. This works great (or
did) until today. I just found out that the "number-format" command in
XSLT can't handle scientific notation! So when I try to format these
numbers I just get "NaN" on the output report!!!

There are only two solutions I can see, and don't know how to
implement either of them. One would be to get XSLT to recognize
scientific notation (not going to happen by me). The other would be to
get the ADO.NET "writeXML" (or more specifically, the XmlDataDocument
class constructor) to not put the recordset double values into
scientific notation (it doesn't do that for all of them, just some of
the numbers).

Can someone help me with a solution? I've been searching the net all
day and don't see any options! I don't want to have to
re-think/re-write the entire reporting structure for my program!

I'm using VB.NET under Visual Studio.NET 2003 with the 1.1 Framework.
Thanks for any help!

---Nick
Nov 12 '05 #1
1 8862
"Nick" <su*****@yahoo. com> wrote in message news:d2******** *************** ***@posting.goo gle.com...
I just found out that the "number-format" command in
XSLT can't handle scientific notation! So when I try to format these
numbers I just get "NaN" on the output report!!! : : get the ADO.NET "writeXML" [...] to not put the recordset double
values into scientific notation (it doesn't do that for all of them, just
some of the numbers).


It only does if for the double-precision values where there are
more than 15 significant digits, right? This is because the double
data type cannot represent greater precision than this.

The simplest recommendation I can make is to change the DataType
of the offending DataColumn(s) in your data set from System.Double
to System.Decimal. Decimal sounds more appropriate to your
situation, and will not produce a text representation in exponential
notation.

If for whatever reason this can't be done, then the next approach I'd
suggest is to look at what WriteXml( ) overload you are using. If the
method takes a TextWriter (as one example), then what you can do
is create a TextWriter wrapper subclass, e.g.

dataSet1.WriteX ml( New ExponentialFilt erTextWriter( Console.Out) )

Your implementation of ExponentialFilt erTextWriter would intercept
Write( ) method calls made by WriteXml, and check whether the
written value is an exponential notation number. When it is, your
filter TextWriter could [possibly parse and] typecast it to Decimal
and then pass along the Decimal's text representation for output.
In all other scenarios, the filter TextWriter passes the output onto
its wrapped TextWriter instance unaltered.
Derek Harmon
Nov 12 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2140
by: masoud bayan | last post by:
I have some values in type of double such 0.00009 , 0.0000007, when I want to show them in a text box and convert them to string they are changed to scientific notation while I want to show them as they are. I tried to use tostring("f") but it needs to have a precision number after *f* which will cause always have fix number of characters (for example if use f10 then 0.09 is converted to 0.09000000 while I need to show it as 0.09). do...
5
17660
by: Dennis Myrén | last post by:
Hi. Is there a way to make sure that float, double and decimal data types never will be presented in a scientific notation? I have tried to round(Math.Round) float's to 7 decimals, double's to 15 and decimals to 28 decimals, but that does not help. And the System.Globalization.NumberFormatInfo class does not seem to provide a such function.
0
1712
by: Greg | last post by:
I am working on an application that requires working with numbers in scientific notation. I am using SqlServer as the database and I have created strongly typed data adapters and datasets. The numbers are defined as numeric in the SqlServer Database and are bound to text boxes in the app. In the dataset xml these numbers are defined as decimal. I am using the binding method Format to display the data in scientific notation and Parse to...
7
10916
by: Dustan | last post by:
How can I get a number into scientific notation? I have a preference for the format '1 E 50' (as an example), but if it's well known, it works.
2
7264
by: Ryan Liu | last post by:
In C#, for a large float (9 digitals), how can I disable Scientific notation. When it auto convert to Scientific notation, I lost accuracy. Thanks a lot! Ryan
9
6668
by: Joe Attardi | last post by:
Hi all, Math is not my strongest area so forgive me if I use some of the wrong terminology. It seems that scientific notation is immune to rounding errors. For example: (4.98 * 100) + 5.51 // returns 503.51000000000005, rounding error! 4.98e2 + 5.51 // returns 503.51, correct!
2
2763
by: rSmoke | last post by:
I have a DataSet that contains a table with about 6 columns of high accuracy decimal values. When I try to write out the DataSet using the WriteXML() function the XML is written fine, but the decimal values are written out in scientific notation ("9.984348392E+08"). This wouldn't be a problem except when I try to READ the XML file back into a DataSet I keep getting a System.FormatException saying "Input string was not in a correct format."...
2
7031
by: Greg | last post by:
I am working on an application that requires working with numbers in scientific notation. I am using SqlServer as the database and I have created strongly typed data adapters and datasets. The numbers are defined as numeric in the SqlServer Database and are bound to text boxes in the app. In the dataset's xml these numbers are defined as decimal. I am using the binding method Format to display the data in scientific notation and Parse to...
5
3630
by: ChopperDave | last post by:
Hi, guys I am a noob at programming full stop and am having to take a unit of it at uni. I currently have an easy part to this assignment and a hard part. I am finishing up the easy part currently which was prompt the user for 10 float values, store them in an array, ouput all 10 but only to 4 decimal places, find the maximum and then output this in scientific notation. I have done everything but have failed to learn how do print it in...
0
8826
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9366
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9316
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9241
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8239
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6793
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6073
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4867
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2211
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.