Re: map:group-by or map:build with a sequence of keys?

Hi Martin,

> Or is the group too busy with the weekly agenda and the official PR way of suggesting/debating things to be able to respond to suggestions on the mailing list?

This might just be it.

Currently, the best place to discuss proposals is the Github repository. I support your suggestion, which is why I didn't add any thoughts.

Best,
Christian



Am 17.10.2022 17:21 schrieb Martin Honnen <martin.honnen@gmx.de>:
Has nobody seen this?

Or is the group too busy with the weekly agenda and the official PR way
of suggesting/debating things to be able to respond to suggestions on
the mailing list?

Am 10/13/2022 um 2:15 PM schrieb Martin Honnen:
>
> When map:group-by was introduced I found the restriction of a single key
> instead of a sequence of keys unnecessarily restrictive (some people on
> Slack agreed), the same appears in my view to be the case for the new
> map:build, I think it could be easily adapted to handle a sequence of
> keys by using e.g.
>
>  fold-left($input, map{}, ->($map, $next) {
>
>   fold-left($key($next), $map, ->($map, $key) {
>    let $nextValue := $value($next) return
>    if (map:contains($map, $key))
>    then map:put($map, $key, $combine($map($key), $nextValue))
>    else map:put($map, $key, $nextValue)})
>  }
> )
>
> as the implementation body/definition of the result of
>
> map:build(
> $input    as item()*,
> $key    as function(item()) as xs:anyAtomicType*    := fn:identity#1,
> $value    as function(item()) as item()*    := fn:identity#1,
> $combine    as function(item()*, item()*) as item()*    := fn:op(',')
> ) as map(*)
>
>
> Use case in my view is the classical example of the XSLT 3 spec where in
> e.g.
>
> <titles>
>     <title>A Beginner's Guide to <ix>Java</ix></title>
>     <title>Learning <ix>XML</ix></title>
>     <title>Using <ix>XML</ix> with <ix>Java</ix></title>
> </titles>
>
> you want to group the "title" elements by the "ix" child elements, with
> the proposed change above that would give e.g.
>
> map {
>   "Java": (<title>A Beginner's Guide to <ix>Java</ix>
> </title>, <title>Using <ix>XML</ix> with <ix>Java</ix>
> </title>),
>   "XML": (<title>Learning <ix>XML</ix>
> </title>, <title>Using <ix>XML</ix> with <ix>Java</ix>
> </title>)
> }
>
>
> XSLT 2/3 grouping always had this feature to allow an item in the
> grouping population to belong to several groups, the above change would
> give that same power to XPath/XQuery based grouping using map:build.
>
>
>
>
>
>
>

Received on Monday, 17 October 2022 16:06:00 UTC