Re: [xml-dev] YPath, ZPath?

From
Michael Kay <>
To
Alain Couthures <>
Date
2016-04-10T21:20:18Z
ID
<>
Thread
Re: [xml-dev] YPath, ZPath?
> 
> I was sorry to read that XQuery 3.1 is not considering JSON data as a tree: JSON is treated as a "complex" atomic type, from my point of view.
> 

You can regard the output of parse-json() as a tree (of maps, arrays, etc), but it is different from the tree representation of XML. The main difference is that the maps, arrays, etc produced by parse-json() have no parent.

This corresponds closely to the way JSON data is handled in other programming languages.

This apparently trivial difference has some interesting and profound consequences. Transformations of a tree in which many branches of the tree remain unchanged become much more efficient, because (in an environment where in-situ update is not allowed) copying a subtree has zero cost. However, the lack of upwards or sideways navigation means that during a recursive descent of the tree, you need to pass a lot more context.

For an exploration of the effect of these differences on some transformation use cases, see my XML Prague 2016 paper.

Michael Kay
Saxonica