473,402 Members | 2,064 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

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 8789
"Nick" <su*****@yahoo.com> wrote in message news:d2**************************@posting.google.c om...
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.WriteXml( New ExponentialFilterTextWriter( Console.Out) )

Your implementation of ExponentialFilterTextWriter 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
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...
5
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...
0
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...
7
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
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
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 ...
2
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...
2
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...
5
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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,...
0
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...

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.