Skip to content

Extend FLWOR expressions to maps #31

@rhdunn

Description

@rhdunn

Edit: Current proposal (#31 (comment)):

for key $key in ...
returnfor value $value in ...
returnfor key $key value $value in ...
return

With the addition of the for member syntax for arrays, it is possible to use a ForExpr/FLWORExpr to enumerate the contents of sequences and arrays, but not maps. In order to be consistent and symmetric across these types, the for member syntax should be extended to support maps by enumerating the key/value entries of the map.

Given a map of type map(K, V) the member RecordTest would be record(key as K, value as V). Given a map of type map(*), the member RecordTest would be record(key, value).

This would allow a user to write expressions like:

for member $entry in $map
return element { $entry?key } { $entry?value }

NOTE: With the addition of the array:values and map:entries functions in issue #29, it is possible to avoid the need of the for member syntax for arrays and maps, but may be worth keeping for people who prefer the wordy style of the XPath/XQuery syntax.

Metadata

Metadata

Assignees

No one assigned

    Labels

    CompletedPR has been applied, tests written and tagged, no further action neededFeatureA change that introduces a new featureXPathAn issue related to XPathXQueryAn issue related to XQuery

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions