<div dir="ltr"><div class="gmail_extra">Hello --</div><div class="gmail_extra"><br></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></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></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></div><div class="gmail_extra">So where map:merge looks like:</div><div class="gmail_extra"><br></div><div class="gmail_extra"><code class="" style="font-weight:bold;color:rgb(0,0,0)">map:merge</code><span style="color:rgb(0,0,0);font-family:sans-serif;font-size:medium;background-color:rgb(255,204,255)">(</span><code class="" style="color:rgb(0,0,0)">$maps</code><code class="" style="color:rgb(0,0,0);white-space:normal"> as </code><code class="" style="font-style:italic;color:rgb(0,0,0)">map(*)*</code><span style="color:rgb(0,0,0);font-family:sans-serif;font-size:medium;background-color:rgb(255,204,255)">)</span><code class="" style="color:rgb(0,0,0);white-space:normal"> as </code><code class="" style="font-style:italic;color:rgb(0,0,0)">map(*)</code><br></div><div class="gmail_extra"><code class="" style="font-style:italic;color:rgb(0,0,0)"><br></code></div><div class="gmail_extra"><code class="" style="color:rgb(0,0,0)">so would</code></div><div class="gmail_extra"><code class="" style="font-style:italic;color:rgb(0,0,0)"><br></code></div><div class="gmail_extra"><code class="" style="font-style:italic;color:rgb(0,0,0)"><code class="" style="font-weight:bold;font-style:normal">map:union</code><span style="font-family:sans-serif;font-size:medium;font-style:normal;background-color:rgb(255,204,255)">(</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:medium;font-style:normal;background-color:rgb(255,204,255)">)</span><code class="" style="font-style:normal;white-space:normal"> as </code><code class="">map(*)</code><br></code></div><div class="gmail_extra"><code class="" style="font-style:italic;color:rgb(0,0,0)"><code class=""><br></code></code></div><div class="gmail_extra"><span style="color:rgb(0,0,0);font-family:sans-serif;font-size:medium">The only change would be:</span></div><div class="gmail_extra"><span style="color:rgb(0,0,0);font-family:sans-serif;font-size:medium"><br></span></div><div class="gmail_extra"><span style="color:rgb(0,0,0);font-family:sans-serif;font-size:medium">The supplied maps are combined as follows:</span><br></div><div class="gmail_extra"><ol class="" style="color:rgb(0,0,0);font-family:sans-serif;font-size:medium"><li><p style="margin-top:0.3em;margin-bottom:0.3em">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>.</p></li><li><p style="margin-top:0.3em;margin-bottom:0.3em">The associated value for each such key is <b>a sequence of values</b> taken from <b>every </b>map in the input sequence <code>$input</code> that contains an entry with this key. </p></li></ol><div><font color="#000000" face="sans-serif" size="3">Would this be a useful thing to add, generall?  (It would certainly be useful to me!)</font></div><div><font color="#000000" face="sans-serif" size="3"><br></font></div><div><font color="#000000" face="sans-serif" size="3">Thanks!</font></div><div><font color="#000000" face="sans-serif" size="3">Graydon</font></div></div></div>