I’ve certainly come across the requirement a few times. It’s not too hard to code:
map:merge( for $k in distinct-values($maps!map:keys()) return map:entry($k, $maps?($k)) ) and we’re at a stage with 3.1 where there’s very little chance of getting a function added if it can be coded as a 2-liner. Michael Kay Saxonica > On 18 Jul 2015, at 18:12, Graydon Saunders <[email protected]> wrote: > > Hello -- > > map:merge returns only the last value associated with the key of a map. Any > other values are lost. > > Sometimes something that returns all of the values is wanted; my particular > present use case is wanting to make sure I've got all the errors associated > with a particular XML node when each rule returns a map using the node > identifier as the key and the error code as the value, but I don't think it's > hard to think of other use cases. > > It's certainly possible to write one's own function to do this but there's > several possible approaches. A built-in could be more readily optimized by > the XQuery processor. (Or at least I hope so!) > > So where map:merge looks like: > > map:merge($maps as map(*)*) as map(*) > > so would > > map:union($maps as map(*)*) as map(*) > > The only change would be: > > The supplied maps are combined as follows: > There is one entry in the returned map for each distinct key present in the > union of the input maps, where two keys are distinct if they are not the > ·same key· <http://www.w3.org/TR/xpath-functions-31/#dt-same-key>. > The associated value for each such key is a sequence of values taken from > every map in the input sequence $input that contains an entry with this key. > Would this be a useful thing to add, generall? (It would certainly be useful > to me!) > > Thanks! > Graydon > _______________________________________________ > [email protected] > http://x-query.com/mailman/listinfo/talk
_______________________________________________ [email protected] http://x-query.com/mailman/listinfo/talk
