<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">I’ve certainly come across the requirement a few times. It’s not too hard to code:</div><div class=""><br class=""></div><div class="">map:merge(</div><div class="">  for $k in distinct-values($maps!map:keys())</div><div class="">  return map:entry($k, $maps?($k))</div><div class="">)</div><div class=""><br class=""></div><div class="">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.</div><div class=""><br class=""></div><div class="">Michael Kay</div><div class="">Saxonica</div><br class=""><div><blockquote type="cite" class=""><div class="">On 18 Jul 2015, at 18:12, Graydon Saunders <<a href="mailto:graydonish@gmail.com" class="">graydonish@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="gmail_extra">Hello --</div><div class="gmail_extra"><br class=""></div><div class="gmail_extra">map:merge returns only the last value associated with the key of a map.  Any other values are lost.</div><div class="gmail_extra"><br class=""></div><div class="gmail_extra">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.</div><div class="gmail_extra"><br class=""></div><div class="gmail_extra">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!)</div><div class="gmail_extra"><br class=""></div><div class="gmail_extra">So where map:merge looks like:</div><div class="gmail_extra"><br class=""></div><div class="gmail_extra"><code class="" style="font-weight: bold;">map:merge</code><span style="font-family: sans-serif; font-size: inherit; background-color: rgb(255, 204, 255);" class="">(</span><code class="" style="">$maps</code><code class="" style="white-space: normal;"> as </code><code class="" style="font-style: italic;">map(*)*</code><span style="font-family: sans-serif; font-size: inherit; background-color: rgb(255, 204, 255);" class="">)</span><code class="" style="white-space: normal;"> as </code><code class="" style="font-style: italic;">map(*)</code><br class=""></div><div class="gmail_extra"><code class="" style="font-style: italic;"><br class=""></code></div><div class="gmail_extra"><code class="" style="">so would</code></div><div class="gmail_extra"><code class="" style="font-style: italic;"><br class=""></code></div><div class="gmail_extra"><code class="" style="font-style: italic;"><code class="" style="font-weight:bold;font-style:normal">map:union</code><span style="font-family: sans-serif; font-size: inherit; font-style: normal; background-color: rgb(255, 204, 255);" class="">(</span><code class="" style="font-style:normal">$maps</code><code class="" style="font-style:normal;white-space:normal"> as </code><code class="">map(*)*</code><span style="font-family: sans-serif; font-size: inherit; font-style: normal; background-color: rgb(255, 204, 255);" class="">)</span><code class="" style="font-style:normal;white-space:normal"> as </code><code class="">map(*)</code><br class=""></code></div><div class="gmail_extra"><code class="" style="font-style: italic;"><br class=""></code></div><div class="gmail_extra"><span style="font-family: sans-serif; font-size: inherit;" class="">The only change would be:</span></div><div class="gmail_extra"><span style="font-family: sans-serif; font-size: inherit;" class=""><br class=""></span></div><div class="gmail_extra"><span style="font-family: sans-serif; font-size: inherit;" class="">The supplied maps are combined as follows:</span><br class=""></div><div class="gmail_extra"><ol class="" style="font-family: sans-serif; font-size: inherit;"><li class=""><div style="margin-top: 0.3em; margin-bottom: 0.3em;" class="">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 <a title="same key" class="" href="http://www.w3.org/TR/xpath-functions-31/#dt-same-key" shape="rect" style="color:rgb(102,0,153);background:transparent"><span class="">·</span>same key<span class="">·</span></a>.</div></li><li class=""><div style="margin-top: 0.3em; margin-bottom: 0.3em;" class="">The associated value for each such key is <b class="">a sequence of values</b> taken from <b class="">every </b>map in the input sequence <code class="">$input</code> that contains an entry with this key. </div></li></ol><div class=""><font face="sans-serif" size="3" class="">Would this be a useful thing to add, generall?  (It would certainly be useful to me!)</font></div><div class=""><font face="sans-serif" size="3" class=""><br class=""></font></div><div class=""><font face="sans-serif" size="3" class="">Thanks!</font></div><div class=""><font face="sans-serif" size="3" class="">Graydon</font></div></div></div>
_______________________________________________<br class=""><a href="mailto:talk@x-query.com" class="">talk@x-query.com</a><br class="">http://x-query.com/mailman/listinfo/talk</div></blockquote></div><br class=""></body></html>