Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xsl] Numbers containing 'e+..' not recognised as numbers

From: Drew McLellan <lists@---------------->
To:
Date: 7/4/2005 7:03:00 PM
On 3 Jul 2005, at 21:34, Dimitre Novatchev wrote:



On 7/4/05, Drew McLellan <lists@xxxxxxxxxxxxxxxx> wrote:



I'm using the MSXML2 processor form with an ASP script, trying to
transform a source xml document to xhtml.

The problem is that my source document contains elements with
attributes whose values are numeric. Sometimes these values are
expressed in a format such as "4.364976000000000e+002". The xsl
processor doesn't recognise these as numbers, and so format-number()
or any function that requires a number as input simply returns NaN.

I've tried using the number() function to convert to a number, but
this has been unsuccessful.

I'd be extremely grateful if anyone could



a) suggest a method to get these numbers recognised as numbers, or
b) suggest the correct mathematical term for these 'e+..' numbers so
I can search more effectively!

I always sucked at mathematics :)




XPath 1.0 does not recognize numbers in scientific notation. XPath  
2.0 does.



I'd therefore recommend using an XSLT 2.0 processor such as Saxon 8.4
or Saxon.NET to solve this problem.

Numbers in scientific notation could be converted to xs:double using
FXSL for XSLT 2.0 in the following way (note that any base -- not only
10 -- is supported):

<suggested solution snipped />



Thanks for the detailed response Dimitre. I'll definitely going to  
look into Saxon.NET for the next phase of this project to see if it  
would be a beneficial solution for us.



For the time being, stuck with the MS processor, I've gone with using  
the msxsl extensions to embed a JScript function to do the  
conversion, as Michael suggested. Every bone in my body hates the  
idea of implementing a vendor-specific extension, but the project is  
tied to Microsoft solutions in other far more drastic ways, so I  
guess I can let it slide ;)



Thanks again for the help.



drew.


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent