Closed michaelhkay closed 6 months ago
Interesting tweak. The majority of the input can be expected to be regular, but I’m trying to understand what we get if we have mixed types:
let $map := map { 1: 1984, 'key': 'value' }
let $seq := ($map, [ $map ])
return $seq?(1, 'key')
Would this give us 1984
, map { 1: 1984, 'key': 'value' }
, value
, value
, as result?
I'm open to suggestions on that. I think the best analogy with the current rules would be that the operator gets applied to EVERY item in the array and it's a type error if any of them fails.
Sounds reasonable. We may additionally need to clarify what happens if arrays are nested:
[ [ [ map { 'x': 'y' } ] ] ]?x → y?
I propose to close this issue, now that we have a more general approach with deep lookups.
The CG agreed to close this issue without further action at meeting 073.
I've been converting the XMark data files and queries from XML to JSON.
Here's part of Q20 in its XML form:
which becomes this, when we access the JSON form of the data:
It can get worse, for example Q16 has
exists ($a?annotation?description?parlist?*?parlist?*?text?*?emph?*?keyword?*?("§"))
These paths arise because a structured derived from JSON often includes map entries whose values are arrays.
It's very hard to get these paths right, and it's hard to produce good diagnostics when you get them wrong.
I'd like to allow the
?*?
"operators" to be replaced with a simple "?". This isn't difficult. Currently the rules for the lookup operator say:All that's needed is to change this to say that if the context item is an array, and the KeySpecifier is an NCName, then the array must be an array of maps and the lookup is applied to these maps.