All of my XSLT is working when using the xml-to-json()
function except for this part,
<number key="send_at">
<xsl:text>1615842000</xsl:text>
</number>
which returns
"send_at":1.615842E9
when I intend to get this result:
"send_at":1615842000
XPath 3.1 (current)
Converting numbers to exponential notation is correct according to the spec (XPath and XQuery Functions and Operators 3.1):
The
fn:xml-to-json
function does allow an$options
argument, which provides a means for implementation-dependent extensions. Saxon 10.5 already leverages this mechanism to support passing through the value, without regard to JSON validity: 1XPath 4 (upcoming)
A formatter is an officially supported option to
fn:xml-to-json
planned for XPath 4: 21 Thanks to Michael Kay for noting this mechanism (and foreseeing its need (and already implementing it in Saxon 10.5)).
2 Thanks to Martin Honnen for noting this XPath 4 update.