Skip to content

Commit 313e9f6

Browse files
committed
XML: Don't parse numbers when converting to JSON
This ensures that version numbers are handled properly.
1 parent b1f34f1 commit 313e9f6

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

tasks/jquery-xml/xml2json.xsl

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@
2323
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
2424
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
2525
THE POSSIBILITY OF SUCH DAMAGE.
26+
27+
====
28+
29+
Modified to remove number parsing so that version numbers like 1.0 are not
30+
converted to the number 1, but stay as a string of "1.0".
2631
-->
2732

2833
<xsl:output indent="no" omit-xml-declaration="yes" method="text" encoding="UTF-8" media-type="text/x-json"/>
@@ -120,12 +125,6 @@
120125
</xsl:choose>
121126
</xsl:template>
122127

123-
<!-- number (no support for javascript mantissa) -->
124-
<xsl:template match="text()[not(string(number())='NaN' or
125-
(starts-with(.,'0' ) and . != '0'))]">
126-
&quot;<xsl:value-of select="."/>&quot;
127-
</xsl:template>
128-
129128
<!-- boolean, case-insensitive -->
130129
<xsl:template match="text()[translate(.,'TRUE','true')='true']">true</xsl:template>
131130
<xsl:template match="text()[translate(.,'FALSE','false')='false']">false</xsl:template>

0 commit comments

Comments
 (0)