XPath/XQuery entry function


Returns a map that contains a single entry (a key-value pair).


$key as xs:anyAtomicType,
$value as item()*
) as map(*)


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


The function map:entry returns a map which normally contains a single entry. The collation of the new map is the default collation from the static context. The key of the entry in the new map is $key, and its associated value is $value.

If the supplied key is the xs:float or xs:double value NaN, the supplied $map is empty (that is, it contains no entries).

If the supplied key is xs:untypedAtomic, it is converted to xs:string.


The expression map:entry("M", "Monday") returns map{"M":"Monday"}.


The function call map:entry(K, V) produces the same result as the expression map{K : V}.

The function map:entry is intended primarily for use in conjunction with the function map:merge. For example, a map containing seven entries may be constructed like this:

map:merge(( map:entry("Su", "Sunday"), map:entry("Mo", "Monday"), map:entry("Tu", "Tuesday"), map:entry("We", "Wednesday"), map:entry("Th", "Thursday"), map:entry("Fr", "Friday"), map:entry("Sa", "Saturday") ))

The map:merge function can be used to construct a map with a variable number of entries, for example:

map:merge(for $b in //book return map:entry($b/isbn, $b))