Changes

Jump to navigation Jump to search
1 byte added ,  14:07, 17 November 2011
no edit summary
The function call <code>[[#map:get|map:get($map, $key)]]</code> can be used to retrieve the value associated with a given key.
A ''map'' can also be viewed as a function from keys to associated values. To achieve this, a map is also a function item. The function corresponding to the map has the signature <code>function($key as xs:anyAtomicType) as item()*</code>. Calling the function has the same effect as calling the <code>get</code> function: the expression <code>$map($key)</code> returns the same result as <code>map:get($map, $key)</code>. For example, if <code>$books-by-isbn</code> is a map whose keys are ISBNs and whose assocated associated values are <code>book</code> elements, then the expression <code>$books-by-isbn("0470192747")</code> returns the <code>book</code> element with the given ISBN. The fact that a map is a function item allows it to be passed as an argument to higher-order functions that expect a function item as one of their arguments. As an example, the following query uses the higher-order function <code>fn:map($f, $seq)</code> to extract all bound values from a ''map'':
<pre class="brush:xquery">
administrator, Bureaucrats, editor, reviewer, Administrators
57

edits

Navigation menu