| XQUERY/XSLT API DOCUMENTATION 4.2 |
All XQuery & XSLT Functions MarkLogic Built-In Functions Admin (xdmp:) AppServer (xdmp:) Classifier (cts:) Debug (dbg:) Document Conversion (xdmp:) Extension (xdmp:) Documents, Directories, Properties, and Locks Functions Extension Functions Function Values Functions HTTP Functions JSON Functions MarkLogic Server Functions Search Functions XML Functions XQuery Context Functions XSLT Functions map (map:) Math (math:) Profile (prof:) Search (cts:) cts:query Constructors Functions Geospatial Functions Geospatial Lexicon Functions Lexicon Functions Search Functions Search Clustering Functions Security (xdmp:) Server Monitoring (xdmp:) Spell (spell:) Update (xdmp:) XQuery Library Modules Admin Library (admin:) Actions Functions Appserver Functions Database Functions Forest Functions Group Functions Host Functions Mimetypes Functions Scheduler Functions Alerting (alert:) Elastic Compute Cloud (ec2:) Entity Enrichment (entity:) Flexible Replication (flexrep:) Geospatial Supporting Functions GEO Functions GeoRSS Functions GML Functions KML Functions MCGM Functions Information Studio (info:) Information Studio Developer (infodev:) Library Services (dls:) cts:query Constructor Functions Document Management Functions Document Update Functions Retention Policy Functions XInclude Functions Modular Documents XInclude Functions XPointer Functions PKI (pki:) Plugin (plugin:) Search (search:) Security-sec (sec:) Spelling Dictionary Management (spell:) Thesaurus (thsr:) Triggers (trgr:) Triggers Library (trgr:) WordProcessingML (ooxml:) ZIP Package (ooxml:) CPF Functions Content Processing Framework (cpf:) CSS Conversion (css:) DocBook Conversion (dbk:) Domains (dom:) Excel Conversion (excel:) Generic Conversion (cvt:) Links (lnk:) MSWord Conversion (msword:) PDF Conversion (pdf:) Pipelines (p:) Powerpoint Conversion (ppt:) XHTML Conversion (xhtml:) W3C-Standard Functions Accessor (fn:) AnyURI (fn:) Boolean (fn:) Context (fn:) DurationDateTime (fn:) Error and Trace (fn:) Node (fn:) Numeric (fn:) QName (fn:) Sequence (fn:) String (fn:) XSLT (fn:) W3C XQuery/XSLT Reference W3C XQuery Functions W3C XQuery Language W3C XSLT Language
This page was generated September 12, 2012 6:00 AM | XQuery & XSLT Built-In & Modules Function Reference
Built-In: map
The map built-in functions are used to create maps. Maps store name-value pairs in an in-memory data structure. You can also persist a map to disk by storing it in a document. Some programming languages implement maps using hash tables, but these map functions make it convenient for you to create and update your own maps. Maps are represented using the `map:map` XQuery primitive type. When you serialize an object of `map:map` type, it serializes to an XML node in the `http://marklogic.com/xdmp/map` namespace.
Function Summary
map:clear | Clear a map.
map:count | Returns the number of entries used in the map.
map:delete | Delete a value from a map.
map:get | Get a value from a map.
map:keys | Get the keys used in the map.
map:map | Creates a map.
map:put | Put a value into a map at the given key.
Function Detail
map:clear(
| $map as map:map
) as empty-sequence()
Summary: Clear a map.
Parameters:
$map : A map.
Example:
      map:clear($table)
      => ()
map:count(
| $map as map:map
) as xs:unsignedInt
Summary: Returns the number of entries used in the map.
Parameters:
$map : A map.
Example:
      map:count($table)
      => 15
map:delete(
| $map as map:map,
| $key as xs:string
) as empty-sequence()
Summary: Delete a value from a map.
Parameters:
$map : A map.
$key : A key.
Example:
      map:delete($table, "some-key")
      => ()
map:get(
| $map as map:map,
| $key as xs:string
) as item()*
Summary: Get a value from a map.
Parameters:
$map : A map.
$key : A key.
Example:
      map:get($table, "some-key")
      => <info>45683</info>
map:keys(
| $map as map:map
) as xs:string*
Summary: Get the keys used in the map.
Parameters:
$map : A map.
Example:
      map:keys($table)
      => ("some-key", "another key", "and another one")
map:map(
| [$map as element(map:map)]
) as map:map
Summary: Creates a map.
Parameters:
$map (optional): A serialized map element.
Example:
      map:map()
      => map:map(<map xmlns="http://marklogic.com/xdmp/map"/>)
Example:
    xquery version "1.0-ml";

    let $map :=
    <map:map xmlns:map="http://marklogic.com/xdmp/map">
     <map:entry>
       <map:key>2</map:key>
       <map:value xsi:type="xs:string"
          xmlns:xs="http://www.w3.org/2001/XMLSchema"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        world</map:value>
     </map:entry>
     <map:entry>
       <map:key>1</map:key>
       <map:value xsi:type="xs:string"
          xmlns:xs="http://www.w3.org/2001/XMLSchema"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        hello</map:value>
     </map:entry>
    </map:map>
    return
    map:get(map:map($map), "2")
    =>
    world
map:put(
| $map as map:map,
| $key as xs:string,
| $value as item()*
) as empty-sequence()
Summary: Put a value into a map at the given key.
Parameters:
$map : A map.
$key : A key. If the key is not unique, it will overwrite the existing key.
$value : A value. If the value is the empty sequence, it will remove the key from the map.
Example:
    let $map := map:map()
    let $put := map:put($map, "some-key",
                      <info>45683</info>)
    return
    <result>{$map}</result>

    =>
    <result>
      <map:map xmlns:map="http://marklogic.com/xdmp/map">
        <map:entry>
          <map:key>some-key</map:key>
          <map:value><info>45683</info></map:value>
        </map:entry>
      </map:map>
    </result>

© Copyright 2002-2012 MarkLogic Corporation. All rights reserved.