xsl-list
[Top] [All Lists]

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

2019-03-12 00:15:39
On Mon, Mar 11, 2019 at 11:33 AM Mukul Gandhi 
<gandhi(_dot_)mukul(_at_)gmail(_dot_)com>
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
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--
<Prev in Thread] Current Thread [Next in Thread>