1
0
mirror of https://gitlab.xiph.org/xiph/icecast-server.git synced 2024-06-16 06:15:24 +00:00

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.
This commit is contained in:
Thomas B. Ruecker 2015-05-16 16:33:15 +00:00
parent 3d2ab9aec2
commit 0b1ac3e9d5

View File

@ -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 -->