The earlier specification converted JSON to a map and this was much
more natural.
Why was it necessary to represent a JSON object as an XML document? I
really don't understand the motives for moving from the more flexible
map-based representation to such artificial, clumsy and unnatural XML
"reflection".
Historically, the answer is that the WGs were for a long time completely
deadlocked on how to add support for arrays to the data model, and without
support for arrays, the JSON-to-maps conversion in the XSLT 3.0 spec was not
viable. The XSLT specification tried to get around this by modelling an array
as a map with integer keys, but it was very clumsy, and had a fatal flaw in
that you need to be able to distinguish an empty array from an empty
map/object. Since there was no sign of the deadlock being resolved, we decided
to abandon the JSON-to-map conversion and fall back to a JSON-to-XML conversion.
In the meantime, XPath 3.1 has come out with a data model for arrays, which
although it has some usability problems, is technically workable. So some of
the original justification for developing the JSON-to-XML conversion has
disappeared. However, I think many people would still consider it useful,
especially as transformation of XML using pattern-matching template rules still
works far better than transformation of JSON-like map/array hierarchies. If you
want to get your JSON into a form where XSLT can manipulate it, converting it
to XML as input to a transformation step is going to work much better than
transforming it to maps and arrays. There are various reasons for this:
patterns for matching nodes are much more powerful than patterns for matching
maps and arrays, and navigation within XML trees using the full set of XPath
axes is much more powerful than navigation within map/array structures.
Plus, of course, arrays might be in XPath 3.1 but they aren't yet in XSLT 3.0.
Michael Kay
Saxonica
--~----------------------------------------------------------------
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
--~--