map:contains

Tests whether a supplied map contains an entry for a given key

Signature

map:contains(
    $map as map(*), 
    $key as xs:anyAtomicType
) as xs:boolean

Properties

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

Rules

The function map:contains returns true if the map supplied as $map contains an entry with the same key as the supplied value of $key; otherwise it returns false.

Examples

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

The expression map:contains($week, 2) returns true().

The expression map:contains($week, 9) returns false().

The expression map:contains(map{}, "xyz") returns false().

The expression map:contains(map{"xyz":23}, "xyz") returns true().

The expression map:contains(map{"abc":23, "xyz":()}, "xyz") returns true().