-
Notifications
You must be signed in to change notification settings - Fork 17
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
Axis steps in lookup expressions #1094
Comments
Interesting indeed…
What concerns me most is terminology. We should figure out what we believe an “entry” is, and use it consistently for the same concept. Can’t we simply return Next, I think
I believe we’ll make everyone’s life easier if we manage to re-use existing terms (from both node traversals and maps/arrays).
I see there’s a need for filtering the results, but I’m not so thrilled that the proposed syntax is easily misinterpreted as a predicate:
Maybe we get the more obvious choice If not, the existing syntax is not sooo bad:
If we do so, it would be consistent to be more liberal for path expressions as well. Otherwise (if I understand you correctly), |
As a first step, I propose that we expand the lookup expression syntax from
to
We'll initially define three axes: We'll define We then define the The I've separated the question of filtering into a separate proposal for a concise syntax for "instance of". Standard predicates can be used with any of the lookup axes to filter the results, for example
|
This issue picks up where issue #341, issue #350, issue #596, issue #960 etc left off - an attempt to find better syntax and semantics for navigation within JTrees (by which I mean trees of maps and arrays). The problems we are addressing are well aired in those previous issues. There are new opportunities for improving navigation within pinned trees, where upwards navigation becomes possible.
Firstly I propose that the existing constructs
?*
,?key
, and?1
be treated as abbreviations for?content::*
,?content::key
, and?content::1
respectively. The content axis delivers a flattened sequence of items.Then I propose we introduce an
entry
axis.?entry::*
,?entry::key
, and?entry::1
deliver their results as a sequence of key value pairs, in the style ofmap:pairs()
. Arrays for this purpose are treated as maps with integer keys. For example if$A
is[(1,2), (3,4)]
then$A?entry::*
delivers(map{'key':1, 'value':(1,2)}, map{'key':2 'value':(3,4)}
.This applies equally to the deep lookup operator.
$A??entry::*
returns all the key-value pairs within the JTree rooted at $A, recursively.We could also consider a
value
axis which delivers a sequence of arrays containing the values, losing the associated keys.If values are labelled, as a result of being found by navigating a pinned JTree. then upwards navigation is also possible. For an item in a pinned tree,
containing-entry::*
delivers the containing entry as a key-value pair. Duplicates are eliminated.owner::*
delivers the immediately containing map or array as identified by the labelownership::*
delivers the transitive closure of theowner::*
axis.peer::*
deliversowner::*/entry::*
following-member::*
delivers the subarray of the containing array that follows the current entrypreceding-member::*
delivers the subarray of the containing array thay precedes the current entryOf course, improved names for these concepts are welcomed!
In these examples I have used
*
to select everything on the relevant axis. This can always be replaced by a key specifier K that selects the item only if it is labelled with a key K. So for example ownership::address selects the containing maps and arrays that are themselves in a map entry with key "address".I think we also need a convenient way to filter the selection by type (see issue #859 for a problem with the current syntax). I propose
??content::[record(longitude, latitude)]
to select all items in the recursive content that match type
record(longitude, latitude)
Similarly
??entry::[array(xs:integer)+]
to select all entries where the value is an array of integers.
Finally, responding to issue #341, I propose that lookup operators should be error free: rather than reporting errors, they should return nothing.
The text was updated successfully, but these errors were encountered: