<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>29660</bug_id>
          
          <creation_ts>2016-05-24 16:06:07 +0000</creation_ts>
          <short_desc>map:remove and array:remove should support removing multiple entries</short_desc>
          <delta_ts>2016-07-21 14:03:38 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>XPath / XQuery / XSLT</product>
          <component>Functions and Operators 3.1</component>
          <version>Candidate Recommendation</version>
          <rep_platform>PC</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>CLOSED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Josh Spiegel">josh.spiegel</reporter>
          <assigned_to name="Michael Kay">mike</assigned_to>
          
          
          <qa_contact name="Mailing list for public feedback on specs from XSL and XML Query WGs">public-qt-comments</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>126561</commentid>
    <comment_count>0</comment_count>
    <who name="Josh Spiegel">josh.spiegel</who>
    <bug_when>2016-05-24 16:06:07 +0000</bug_when>
    <thetext>I think it may improve usability if we modify map:remove to take a sequence of key values instead of a single key value.  This would make it easier to conditionally remove entries from a map.

Consider this map:

   declare variable $m := map {
     0 : &quot;blue&quot;,
     2 : &quot;red&quot;,
     4 : &quot;blue&quot;,
     6 : &quot;green&quot;
   };

Assume the goal is to remove the &quot;blue&quot; entries without knowing the keys in advance.  I came up with two solutions for this.  The first uses a recursive user defined function:

  declare function local:removeAll($m as map(*), $keys) {
    if (exists($keys)) then
       local:removeAll(map:remove($m,$keys[1]), tail($keys))
    else
       $m
  };

  local:removeAll($m, map:keys($m)[$m(.) eq &quot;blue&quot;])

Here is another solution that filters and reconstructs:

  map:merge(
    for $k in map:keys($m)
    where $m($k) ne &quot;blue&quot;
    return 
      map:entry($k, $m($k))
  )


It is more succinct and I think more intuitive to use map:remove directly:

  map:remove($m, map:keys($m)[$m(.) eq &quot;blue&quot;])

If this change makes sense, then I expect we would want to consider making a similar change to array:remove as well.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>126613</commentid>
    <comment_count>1</comment_count>
    <who name="Josh Spiegel">josh.spiegel</who>
    <bug_when>2016-05-27 15:53:45 +0000</bug_when>
    <thetext>This proposal was accepted at XML Query/XSL WG Joint Teleconference #644 on 2016-05-24.

DECISION: Modify map:remove() and array:remove() to allow multiple key arguments as requested by bug 29660.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>126624</commentid>
    <comment_count>2</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2016-05-28 17:43:37 +0000</bug_when>
    <thetext>The changes have been applied to the F+O 3.1 and XSLT 3.0 specifications (but not yet committed).</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>