Commit 0b1ac3e9 authored by Thomas B. Rücker's avatar Thomas B. Rücker 😊

Essential part of upstream pull req No. 20

https://github.com/doekman/xml2json-xslt/pull/20

 Some numeric values would not get formatted to valid JSON. This
 incorporates the suggestions from issue #15.

Also fixed whitespace of original patch.
Additional fix for related issue will follow.
parent 3d2ab9ae
......@@ -125,8 +125,22 @@
<!-- number (no support for javascript mantissa) -->
<xsl:template match="text()[not(string(number())='NaN' or
(starts-with(.,'0' ) and . != '0'))]">
<xsl:value-of select="."/>
(starts-with(.,'0' ) and . != '0' and not(starts-with(.,'0.' ))) or
(starts-with(.,'-0' ) and . != '-0' and not(starts-with(.,'-0.' ))))]">
<xsl:choose>
<xsl:when test="starts-with(.,'.')">
<xsl:value-of select="concat('0',.)"/>
</xsl:when>
<xsl:when test="starts-with(.,'-.')">
<xsl:value-of select="concat('-0.', substring(.,3))"/>
</xsl:when>
<xsl:when test="substring(., string-length(.))='.'">
<xsl:value-of select="concat(.,0)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- boolean, case-insensitive -->
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment