[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

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

Subject: Re: is XPath 3.1 xml-to-json() function useful
From: "David Maus lists@xxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 8 Mar 2019 12:00:07 -0000
Re:  is XPath 3.1 xml-to-json() function useful
On Fri, 08 Mar 2019 12:49:28 +0100,
Mukul Gandhi gandhi.mukul@xxxxxxxxx wrote:
> [1  <text/plain; UTF-8 (7bit)>]
> [2  <text/html; UTF-8 (quoted-printable)>]
> Hi all,
>    I find the XPath 3.1 function json-to-xml() quite useful. It can
>    convert any JSON input to an XML representation. But I'm not
>    convinced that XPath 3.1's xml-to-json() function (as defined in
>    the spec) is much useful.

It is very useful to me because it gives full control over the JSON

At work we recently started to publish descriptions of digital objects
as IIIF Manifests [1]. IIIF Manifest is a JSON-based metadata format,
the source of the object descriptions is in XML.

Example: Manuscript Cod. Guelf. 35 Helmst.

XML: https://github.com/dmj/diglib-iiif/blob/master/examples/mss/35-helmst/mets.xml
JSON: http://iiif.hab.de/object/mss_35-helmst/manifest.json
XSL: https://github.com/dmj/diglib-iiif/blob/master/src/IIIF/Mapper/METS2IIIFv2.xsl

Not sure if a 'generic' XML to JSON conversion would be of much
help. Being explicit about the JSON structure makes the transformation

  -- David

> Taking an example from XPath 3.1 F&O spec, the following XML document
> <array xmlns="http://www.w3.org/2005/xpath-functions"><number>1</number><string>is</string><boolean>1</boolean></array>
> converts into following JSON by the function xml-to-json(),
> [1,"is",true]
> (which is fine)
> But as per the XPath 3.1 F&O spec, simple XML documents like,
> <root>
>    <val>1</val> 
>    <val>2</val>
>    <val>3</val>
>    <val>4</val>
> </root>
> cannot be converted into JSON, by the function xml-to-json(), since the XML input doesn't conform to structure like <array>, <number>, <string> etc (which looks to me, a very limited capability given to the xml-to-json() function).
> Any comments would be useful.
> -- 
> Regards,
> Mukul Gandhi
> XSL-List info and archive 
> EasyUnsubscribe (by email) 

David Maus M.A.

Www: http://dmaus.name
Twitter: @_dmaus

Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.