doekman / xml2json-xslt

Automatically exported from code.google.com/p/xml2json-xslt
BSD 3-Clause "New" or "Revised" License
38 stars 17 forks source link

Strings terminating "E" or "e" are not escaped #17

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
XML like "...<node>8220E</node>..." will output "'node': 8220E, ...

I've changed the number test, which seems to solve the problem:

<xsl:template match="text()[not(string(number())='NaN' or (starts-with(.,'0' ) 
and . != '0')) and not(substring(., string-length(.)) = 'E') and 
not(substring(., string-length(.)) = 'e')]">

Original issue reported on code.google.com by mikhail....@gmail.com on 26 Aug 2011 at 4:47

GoogleCodeExporter commented 9 years ago
Oops. "123E+" also got converted into "number". Proposed fix:

<xsl:template match="text()[not(string(number())='NaN' or (starts-with(.,'0' ) 
and . != '0')) and not(contains(., 'E')) and not(contains(., 'e'))]">

Original comment by mikhail....@gmail.com on 26 Aug 2011 at 4:53

GoogleCodeExporter commented 9 years ago
That is because, underlying java script function is treating 10e4 or 10E4 to be 
a valid number, same as 10000, not sure if you can ask for enhancement on 
JavaScript function itself :) but till that is done, this fix would help for 
sure. 

Original comment by findsand...@gmail.com on 12 Jan 2015 at 10:04