We have to transform some XML that contain numbers in exponent (aka scientific) notation eg.
<Value>12.34e12</Value> <Value>-12.34e-12</Value>
rather irritatingly, we cannot use the sum() function and the like because the XSLT parser expects numbers to be in decimal format.
[We are using the .Net XslCompiledTransform class to do the transform but I think this problem is common to all XSLT implementations]
The only solution to this problem that we have so far is to transform the string value to a number using a javascript function (see below) and then write our own sum template which calls this function.
It seems to me that there must be a better way - is there?
/* This function attempts to coerce the input into a number. */ function toNumber( x ) { if(!x) { return Number.NaN; } if(typeof x === 'number') { return x; } return parseFloat(x); };