By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,743 Members | 1,018 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,743 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
"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 discussion thread is closed

Replies have been disabled for this discussion.