Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Navigation in JSON trees #1775

Open
michaelhkay opened this issue Feb 6, 2025 · 2 comments
Open

Navigation in JSON trees #1775

michaelhkay opened this issue Feb 6, 2025 · 2 comments
Labels
Feature A change that introduces a new feature XPath An issue related to XPath XQFO An issue related to Functions and Operators XQuery An issue related to XQuery

Comments

@michaelhkay
Copy link
Contributor

michaelhkay commented Feb 6, 2025

I propose that the parse-json function should create a pinned tree, so that upwards navigation to parent and ancestor j-nodes becomes possible.

I propose introducing the key specifier .., with $M?.. being a shorthand for ($M => label())?parent, giving a convenient and familiar way to navigate from a j-node to its parent in a pinned tree. For example, $M?..?name gives the value of the name property in the immediately containing map.

Similarly, I propose introducing the key specifier ... to navigate to ancestors, so $M?... becomes a shorthand for ($M => label())?ancestors(), and $M?...?name returns the name property of all containing maps.

For symmetry I suggest we also provide ... as an abbreviated axis step, short for ancestor::node().

I'd like to find a better name for "pinned". Perhaps "tracked" better captures that what it does is to track downward navigation steps and make them reversible.

I'd also like to introduce the terms j-tree and j-node. A j-tree is a map or array, recursively expanded to include its entries or members. A j-node is a value in a j-tree. Perhaps confine the usage to maps and arrays that have been pinned/tracked.

@michaelhkay michaelhkay added XPath An issue related to XPath XQuery An issue related to XQuery XQFO An issue related to Functions and Operators Feature A change that introduces a new feature labels Feb 6, 2025
@michaelhkay
Copy link
Contributor Author

The other label property that's very useful is the key property. `I can't immediately think of nice syntax for getting that. The fn:key() function, of course, is already taken in XSLT.

@michaelhkay
Copy link
Contributor Author

The .. syntax also gives the ability to detect that we're at the top of the tree using match=".[empty(?..)]" -- something that we observed was lacking in the case-study at #1786 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature A change that introduces a new feature XPath An issue related to XPath XQFO An issue related to Functions and Operators XQuery An issue related to XQuery
Projects
None yet
Development

No branches or pull requests

1 participant