[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Recovering the 'document order' of parsed json

Subject: Re: [xsl] Recovering the 'document order' of parsed json
From: "Tony Graham" <tgraham@xxxxxxxxxx>
Date: Tue, 29 Oct 2013 13:31:55 -0000 (GMT)

On Tue, October 29, 2013 12:23 pm, David Cramer wrote:
> Sure it's true that json maps are not ordered, but for documentation
> purposes it is often helpful to present items in a logical order.
> Consider the code sample in:
> https://github.com/rackerlabs/otter/blob/master/docbook/src/docbkx/samples/reqCreatePolicy-changePercentAlarm.json
> When you make the api call, it doesn't matter what order you list name,
> changePercent, cooldown, type, and args, but for the purposes of
> documenting the request, starting with "name" will look a lot more
> natural and logical than starting with "args".

So would you be better off with a XML representation of the JSON rather
than the JSON as XSLT/XPath datatypes?

There is, e.g., David Lee's "JSON XML Schema (JXML)" at
http://xml.calldei.com/JsonXML, but given his stated conceptual
difficulties with XSLT, he's unlikely to have produced a XSLT library for
parsing JSON into JXML.

I've also found http://www.gerixsoft.com/blog/xslt/json2xml and
https://dnovatchev.wordpress.com/2007/07/05/transforming-json/ but YMMV
since you may just be wanting elements for the different JSON types as in
JXML rather than turning JSON names into XML element names as in the other
approaches that I've seen.


Tony Graham                                   tgraham@xxxxxxxxxx
Consultant                                 http://www.mentea.net
Mentea       13 Kelly's Bay Beach, Skerries, Co. Dublin, Ireland
 --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --
    XML, XSL-FO and XSLT consulting, training and programming
       Chair, Print and Page Layout Community Group @ W3C

Current Thread