| re: XSLT number-format command and scientific notation (HELP!)
"Nick" <suschnl@yahoo.com> wrote in message news:d2854c47.0402171355.1f5ce6eb@posting.google.c om...[color=blue]
> 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!!![/color]
: :[color=blue]
> 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).[/color]
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 |