Re: [xsl] is XPath 3.1 xml-to-json() function useful

Subject: Re: [xsl] is XPath 3.1 xml-to-json() function useful
From: "Mukul Gandhi gandhi.mukul@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 12 Mar 2019 05:15:33 -0000
On Mon, Mar 11, 2019 at 11:33 AM Mukul Gandhi <gandhi.mukul@xxxxxxxxx>
wrote:

> Lets say, we've a following input XML document,
>
> <?xml version="1.0" encoding="UTF-8"?>
> <root>
>    <val>1</val>
>    <val>2</val>
>    <val>3</val>
>    <val>4</val>
> </root>
>
> I would want to transform above XML document to following JSON,
>
> {
>     "root": {
>         "val": [
>             1,
>             2,
>             3,
>             4
>         ]
>     }
> }
>

For the interest of readers, I actually got above XML to JSON conversion
done using <oXygen/> XML editor, and then we (actually Martin) solved this
with XSLT 3.0. As a best practice to convert XML into JSON using XSLT 3.0,
I think its a good idea to get a feel of the suitable JSON document for a
XML document, using tool like <oXygen/> XML, and then automate this with a
XSLT 3.0 & XPath 3.1 solution.

Without support of a tool like <oXygen/> XML, I think it'll be harder for
an average developer using XSLT 3.0 to produce XML to JSON conversions.




-- 
Regards,
Mukul Gandhi

Current Thread