XPath/XQuery remove function

Summary

Returns a map containing all the entries from a supplied map, except those having a specified key.

Signature

map:remove(
$map as map(*),
$keys as xs:anyAtomicType*
) as map(*)

Properties

This function is deterministic, context-independent, and focus-independent.

Rules

The function map:remove returns a map containing all the entries in $map except for any entry whose key is the same key as an item in $keys.

No failure occurs if an item in $keys does not correspond to any entry in $map; that key value is simply ignored.

The effect of the function call map:remove($MAP, $KEY) can be described more formally as the result of the expression below:

map:merge (
    map:for-each (
       $MAP, function($k, $v) { 
               if (some $key in $KEY satisfies (op:same-key($k, $key)) 
               then () 
               else map:entry($k, $v)
             } ) ) 

Examples

let $week := map{0:"Sonntag", 1:"Montag", 2:"Dienstag", 3:"Mittwoch", 4:"Donnerstag", 5:"Freitag", 6:"Samstag"}

The expression map:remove($week, 4) returns map{0:"Sonntag", 1:"Montag", 2:"Dienstag", 3:"Mittwoch", 5:"Freitag", 6:"Samstag"}.

The expression map:remove($week, 23) returns map{0:"Sonntag", 1:"Montag", 2:"Dienstag", 3:"Mittwoch", 4:"Donnerstag", 5:"Freitag", 6:"Samstag"}.

The expression map:remove($week, (0, 6 to 7)) returns map{1:"Montag", 2:"Dienstag", 3:"Mittwoch", 4:"Donnerstag", 5:"Freitag"}.

The expression map:remove($week, ()) returns map{0:"Sonntag", 1:"Montag", 2:"Dienstag", 3:"Mittwoch", 4:"Donnerstag", 5:"Freitag", 6:"Samstag"}.