| 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 5:59 AM | XQuery & XSLT Built-In & Modules Function Reference
Built-In: Extension - MarkLogic Server Functions
The MarkLogic Server extension functions are XQuery extensions that return MarkLogic Server-specific information, such as the version of MarkLogic Server, the IDs of the hosts in the cluster, and so on.
Function Summary
xdmp:access | Returns whether a given action on the specified document URI would succeed.
xdmp:architecture | Returns the hardware architecture upon which MarkLogic Server is running.
xdmp:collation-canonical-uri | Returns the canonical URI for the given URI, if it represents a valid collation.
xdmp:database | Returns the the ID of the database named in the the parameter.
xdmp:database-forests | Returns a sequence of forest IDs in the specified database.
xdmp:database-name | Return the name of the database with the given ID.
xdmp:databases | Returns a sequence of the IDs of all the databases in the system.
xdmp:document-forest | Returns the forest ID of the forest in which a document (or a lock or a property) with the specified URI is stored.
xdmp:document-get | Returns the document in the file specified by $location.
xdmp:elapsed-time | Returns the elapsed time since the start of processing of this query.
xdmp:forest | Returns the the ID of the forest specified as the parameter.
xdmp:forest-databases | Returns the database ID corresponding to the database to which the specified forest belongs.
xdmp:forest-name | Return the name of the forest with the given id.
xdmp:forests | Returns a sequence of the IDs of all the forests in the system.
xdmp:get | [DEPRECATED: use xdmp:document-get instead] Returns the document in the XML file specified by $path.
xdmp:group-hosts | Returns the IDs of all hosts belonging to the group with the given ID.
xdmp:group-name | Returns the the name of the group with the given ID.
xdmp:group-servers | Returns the the IDs of all App Servers belonging to the group with the given ID.
xdmp:groups | Returns a sequence of the IDs of all the groups in the system.
xdmp:host | Returns the the ID of the host named in the parameter.
xdmp:host-name | Returns the the name of the host ID specified as the parameter.
xdmp:hosts | Returns a sequence of the IDs of all the hosts in the system.
xdmp:log | Logs a debug message to the log file <install_dir>/Logs/ErrorLog.txt.
xdmp:log-level | Retrieves the current server log level.
xdmp:modules-database | Returns the database ID of the modules database.
xdmp:modules-root | Returns the current root path for modules.
xdmp:platform | Returns the operating-system platform upon which MarkLogic Server is running ("solaris", "winnt", "linux", or "macosx").
xdmp:pretty-print | Returns a well-formatted XQuery module.
xdmp:product-edition | Returns the current MarkLogic product edition.
xdmp:query-meters | Returns the current value of the resource meters for this query sequence.
xdmp:query-trace | Enables or disables tracing of this query.
xdmp:request | Returns the unique key of the current request.
xdmp:rethrow | Within the catch section of a try-catch expression, re-throw the currently caught error.
xdmp:schema-database | Returns the database ID of the schema database associated with the current database.
xdmp:security-database | Returns the database ID of the security database associated with the current database.
xdmp:server | Returns the the ID(s) of the App Server specified in the parameter.
xdmp:server-name | Return the name of the App Server with the given ID.
xdmp:servers | Returns a sequence of the IDs of all the App Servers in the system.
xdmp:subbinary | Returns a binary node made up of a subset of the given binary node.
xdmp:trace | Signal a trace event.
xdmp:triggers-database | Returns the database ID of the triggers database associated with the current database.
xdmp:uri-content-type | Returns the content type of the given URI as matched in the mimetypes configuration.
xdmp:uri-format | Returns the format of the given URI as matched in the mimetypes configuration.
xdmp:version | Returns the current MarkLogic Server version.
Function Detail
xdmp:access(
| $uri as xs:string,
| $action as xs:string
) as xs:boolean
Summary: Returns whether a given action on the specified document URI would succeed.
Parameters:
$uri : The document URI.
$action : The type of access: "create", "insert", "update", or "execute".
Example:
      xdmp:access(
             "http://example.com/foo.xml",
             "create")
       => true()
xdmp:architecture( ) as xs:string
Summary: Returns the hardware architecture upon which MarkLogic Server is running. If `xdmp:platform()` returns "linux", it will return "x86_64" or "i686. If `xdmp:platform()` returns "solaris", it will return "amd64" or "sparcv9". If `xdmp:platform()` returns "winnt", it will return "amd64" or "i686". If `xdmp:platform()` returns "macosx", it will return "x86_64".
Example:
      xdmp:architecture()
       => "amd64"
xdmp:collation-canonical-uri(
| $collation-uri as xs:string
) as xs:string
Summary: Returns the canonical URI for the given URI, if it represents a valid collation. A canonical URI is the unique string MarkLogic Server uses to identify a given collation. The canonical URI string places any attributes that occur in the URI in a predefined order, and it removes any attributes that are redundant due to locale defaults.
Parameters:
$collation-uri : A collation URI.
Usage Notes: If the specified collation URI is not a valid URI, an exception is thrown.
Example:
    xdmp:collation-canonical-uri("http://marklogic.com/collation/en/S3")
    => http://marklogic.com/collation/en
xdmp:database(
| [$name as xs:string]
) as xs:unsignedLong
Summary: Returns the the ID of the database named in the the parameter. Returns the ID of the current database if no parameter is specified.
Parameters:
$name (optional): The name of the database. The default value is the name of the current database.
Example:
      xdmp:database("myDB")
      => 74495681647284736476
xdmp:database-forests(
| $database as xs:unsignedLong,
| [$include-replicas as xs:boolean?]
) as xs:unsignedLong*
Summary: Returns a sequence of forest IDs in the specified database.
Parameters:
$database : A database ID.
$include-replicas (optional): True if replica forest ids should also be included.
Example:
      xdmp:database-forests(xdmp:database("Documents"))
      => (8456374036761185098, 10615125154705099114)
xdmp:database-name(
| $id as xs:unsignedLong
) as xs:string
Summary: Return the name of the database with the given ID.
Parameters:
$id : A database ID.
Example:
    xdmp:database-name(8456374036761185098)
    => "Documents"
xdmp:databases( ) as xs:unsignedLong*
Summary: Returns a sequence of the IDs of all the databases in the system.
Example:
      xdmp:databases()
       => (14389140626518478220,
              8456374036761185098,
    	  10615125154705099114)
xdmp:document-forest(
| $uri as xs:string,
| [$forest-ids as xs:unsignedLong*]
) as xs:integer?
Summary: Returns the forest ID of the forest in which a document (or a lock or a property) with the specified URI is stored. Otherwise, returns the empty sequence.
Parameters:
$uri : The URI of the document, lock, or property.
$forest-ids (optional): Restricts the ID(s) of the forest(s) in which this function may return.
Example:
      xdmp:document-forest("example.xml")
      => 12972338785465832200
xdmp:document-get(
| $location as xs:string,
| [$options as node()?]
) as node()
Summary: Returns the document in the file specified by $location.
Parameters:
$location : The location of the input document. If the scheme of the location is HTTP (that is, if the string starts with "http://"), then the document is requested over HTTP. If the scheme is file (that is, if the string starts with "file://"), then the document is requested over file protocol from the local filesystem. Otherwise, the document is fetched from the local filesystem. On the filesystem, the path can be fully qualifed or relative. Relative pathnames are resolved from the directory in which MarkLogic Server is installed.
$options (optional): The options node for getting this document. The default value is (). The node for the xdmp:document-get options must be in the `xdmp:document-get` namespace. This parameter can also include option elements in the `xdmp:http` namespace for the HTTP parameters. The `xdmp:document-get` options include: <default-namespace> The namespace to use if there is no namespace at the root node of the document. The default value is "". <repair> A value of `full` specifies that malformed XML content be repaired. A value of `none` specifies that malformed XML content is rejected. If no repair option is explicitly specified, the default is implicitly specified by the XQuery version of the caller. In XQuery `1.0` and `1.0-ml` the default is `none`. In XQuery `0.9-ml` the default is `full`. This option has no effect on binary or text documents. <format> A value of `text` specifies to get the document as a text document, regardless of the URI specified. A value of `binary` specifies to get the document as a binary document, regardless of the URI specified. A value of `xml` specifies to get the document as an XML document, regardless of the URI specified. <default-language> The language to specify in an `xml:lang` attribute on the root element node if the root element node does not already have an `xml:lang` attribute. If `default-language` is not specified, then nothing is added to the root element node. <encoding> Specifies the encoding to use when reading the document into MarkLogic Server. Supported values include `UTF-8`, `ISO-8859-1`, as well as many other popular encodings. See the Search Developer's Guide for a list of character set encodings by language. All encodings will be translated into UTF-8 from the specified encoding. The string specifed for the `encoding` option will be matched to an encoding name according to the Unicode Charset Alias Matching rules (http://www.unicode.org/reports/tr22/#Charset_Alias_Matching). An automatic encoding detector will be used if the value `auto` is specified. If no encoding can be detected, the encoding defaults to UTF-8. If no encoding option is specified, the encoding defaults to the encoding specified in the http header (if using with one of the http functions, for example, `xdmp:http-get`), otherwise it defaults to UTF-8; any encoding http headers are ignored if there is any value specified for the `encoding` option.
Required Privilege: `http://marklogic.com/xdmp/privileges/xdmp-document-get`
Usage Notes: If no format is specified in $options, and the document is from an HTTP server, the format is specified by the document content type from the HTTP response. If no format is specified in $options, and the document is from the filesystem, the format is specified by the document content type from the filename extension. The mimetype extensions and corresponding content types are set in the Admin Interface. If no `repair` option is specified, the default is specified by the XQuery version of the caller. In XQuery version `1.0` and `1.0-ml` the default is `<repair>none</repair>`. In XQuery version `0.9-ml` the default is `<repair>full</repair>`. When the document is from an HTTP server, `xdmp:document-get` will always return the response from the HTTP server, even if it is an error response such as 404 or 500. If you want to be able to examine the response header in your application, use the `xdmp:http-get` instead, which returns both the response header and the response.
Example:
      xdmp:document-get("myDocument.xml")
      => the xml contained in myDocument.xml,
            for example, <myDocument/>
Example:
      xdmp:document-get("myDocument.html",
           <options xmlns="xdmp:document-get">
               <repair>full</repair>
           </options>)
      => myDocument.html as an XML document that has gone
         through any needed tag repair
Example:
      xdmp:document-get("http://myCompany.com/file.xml",
           <options xmlns="xdmp:document-get"
                    xmlns:http="xdmp:http">
               <format>xml</format>
               <http:authentication>
    	      <http:username>user</http:username>
    	      <http:password>pass</http:password>
    	   </http:authentication>
           </options>)
      => gets an XML document named file.xml, sending the
         authentication credentials user/pass to the
         http://myCompany.com server
xdmp:elapsed-time( ) as xs:dayTimeDuration
Summary: Returns the elapsed time since the start of processing of this query. Gives the same information as the `elapsed-time` element of the `xdmp:query-meters` output, but has less overhead than calling `xdmp:query-meters`.
Usage Notes: Certain operations are run concurrently with the timing operations, and if those operations are not actually used in the query, they might not be included in the timings. This occurs for operations like `xdmp:estimate`, `xdmp:exists`, and lexicon calls (for example, `cts:element-values`). If you want to see the total timings that include calls that are not used, you can form some other expression with the results of the calls. For example, if you have an expression that calls `xdmp:estimate` in a `let` expression, you can add 0 to the output, which causes it to be included in the timings (something like `xdmp:estimate($query) + 0`).
Example:
    xquery version "1.0-ml";

    fn:count(collection()),
    xdmp:elapsed-time()

    => The count of the number of documents in the database followed by
       the elapsed-time of the query:

       153
       PT0.04S
xdmp:forest(
| $name as xs:string
) as xs:unsignedLong
Summary: Returns the the ID of the forest specified as the parameter.
Parameters:
$name : The name of the forest.
Example:
      xdmp:forest("myForest")
      => 15495681647217162987
xdmp:forest-databases(
| $forest as xs:unsignedLong
) as xs:unsignedLong
Summary: Returns the database ID corresponding to the database to which the specified forest belongs.
Parameters:
$forest : A forest ID.
Example:
      xdmp:forest-databases(xdmp:forest("Documents"))
      => 2032458498523149048
xdmp:forest-name(
| $id as xs:unsignedLong
) as xs:string
Summary: Return the name of the forest with the given id.
Parameters:
$id : A forest ID.
Example:
    xdmp:forest-name(8456374036761185098)
    => "Documents"
xdmp:forests( ) as xs:unsignedLong*
Summary: Returns a sequence of the IDs of all the forests in the system.
Example:
      xdmp:forests()
       => 18263538320779601865
    2760886727871312968
    1551965607977434000
    2714941248661564752
xdmp:get(
| $path as xs:string,
| [$default-namespace as xs:string?],
| [$options as xs:string*]
) as node()
Summary: [DEPRECATED: use `xdmp:document-get` instead] Returns the document in the XML file specified by $path. This function is deprecated and will be removed from a future release. Use `xdmp:document-get` instead.
Parameters:
$path : The path to the input file. The path can be fully qualifed or relative. Relative pathnames are resolved from the directory in which MarkLogic Server is installed.
$default-namespace (optional): Default namespace for nodes in the first parameter. If $default-namespace is specified and the root node of the loaded document does not explicitly specify a namespace, $default-namespace will be applied to the root node. The default value for $default-namespace is "".
$options (optional): The options for getting this document. The default value is (). Options include: "repair-full" Specifies that malformed XML content be repaired. This option has no effect on binary or text documents. "repair-none" Specifies that malformed XML content be rejected. This option has no effect on binary or text documents. "format-text" Specifies to get the document as a text document, regardless of the URI specified. "format-binary" Specifies to get the document as a binary document, regardless of the URI specified. "format-xml" Specifies to get the document as an XML document, regardless of the URI specified. "lang=en" Specifies that the document is in english.
Usage Notes: If no format is specified in $options, it is specified by the document content type specified by the extension of the document URI. The mimetype extensions and corresponding content types are set in the Admin Interface. If neither "repair-full" nor "repair-none" is present, the default is specified by the XQuery version of the caller. In XQuery version `1.0` and `1.0-ml` the default is "repair-none". In XQuery version `0.9-ml` the default is "repair-full".
Example:
      xdmp:get("foo.xml")
      => <foo/>
Example:
      xdmp:get("foo.html", "", ("repair-full", "format-xml"))
      => foo.html as an XML document that has gone through any
            needed tag repair
xdmp:group-hosts(
| [$name as xs:unsignedLong]
) as xs:unsignedLong*
Summary: Returns the IDs of all hosts belonging to the group with the given ID. If no parameter is specified, it uses the group of the current host.
Parameters:
$name (optional): The ID of the group. The default value is the id of the group the current host belongs to.
Example:
      xdmp:group-hosts(134722342511344334243)
      => 18263538320779601865
    2760886727871312968
xdmp:group-name(
| [$name as xs:unsignedLong]
) as xs:string
Summary: Returns the the name of the group with the given ID. Returns the name of the current group if no parameter is specified.
Parameters:
$name (optional): The id of the group. The default value is the id of the group the current host belongs to.
Example:
      xdmp:group-name(134722342511344334243)
      => "Default"
xdmp:group-servers(
| [$name as xs:unsignedLong]
) as xs:unsignedLong*
Summary: Returns the the IDs of all App Servers belonging to the group with the given ID. If no parameter is specified, it uses the group of the current host.
Parameters:
$name (optional): The ID of the group. The default value is the ID of the group to which the current host belongs.
Example:
      xdmp:group-servers(xdmp:group("Default"))
       => 18263538320779601865
           2760886727871312968
           2714941248661564752
xdmp:groups( ) as xs:unsignedLong*
Summary: Returns a sequence of the IDs of all the groups in the system.
Example:
      xdmp:groups()
       => 12363538320723601865
    2350822345151312968
    7891965607973455300
    2314941134541564752
xdmp:host(
| [$name as xs:string]
) as xs:unsignedLong
Summary: Returns the the ID of the host named in the parameter. Returns the ID of the current host if no parameter is specified.
Parameters:
$name (optional): The name of the host. The default value is the name of the current host.
Example:
      xdmp:host("foo.example.com")
      => 15495681647217162987
xdmp:host-name(
| $ID as xs:unsignedLong
) as xs:string
Summary: Returns the the name of the host ID specified as the parameter. Returns the current host if no name is specified.
Parameters:
$ID : A host ID.
Example:
      xdmp:host-name(15495681647217162987)
      => foo.example.com
xdmp:hosts( ) as xs:unsignedLong*
Summary: Returns a sequence of the IDs of all the hosts in the system.
Example:
      xdmp:hosts()
       => 18263538320779601865
    2760886727871312968
    1551965607977434000
    2714941248661564752
xdmp:log(
| $msg as item()*,
| [$level as xs:string?]
) as empty-sequence()
Summary: Logs a debug message to the log file `<install_dir>/Logs/ErrorLog.txt`.
Parameters:
$msg : Message for logging.
$level (optional): One of: emergency, alert, critical, error, warning, notice, info, config, debug, fine, finer, or finest. The default level is "info".
Example:
      xdmp:log("AAAA")
      => ()
xdmp:log-level( ) as xs:string
Summary: Retrieves the current server log level.
Example:
      xdmp:log-level()
      => finest
xdmp:modules-database( ) as xs:unsignedLong
Summary: Returns the database ID of the modules database. Returns 0 if the current App Server uses the file system for its modules.
Example:
      xdmp:modules-database()
      => 8447094497219470018
xdmp:modules-root( ) as xs:string
Summary: Returns the current root path for modules.
Example:
      xdmp:modules-root()
       => Docs
xdmp:platform( ) as xs:string
Summary: Returns the operating-system platform upon which MarkLogic Server is running ("solaris", "winnt", "linux", or "macosx").
Example:
      xdmp:platform()
       => "winnt"
xdmp:pretty-print(
| $xquery as xs:string
) as xs:string
Summary: Returns a well-formatted XQuery module.
Parameters:
$xquery : An XQuery module to be reformatted.
Example:
      xdmp:pretty-print("for $x in 1 to 10 return $x")
       => "for $x in 1 to 10
           return $x"
xdmp:product-edition( ) as xs:string
Summary: Returns the current MarkLogic product edition.
Example:
      xdmp:product-edition()
       => "Standard"
xdmp:query-meters( ) as element()
Summary: Returns the current value of the resource meters for this query sequence.
Usage Notes: The resource meters returned include: elapsed-time The time elapsed since the start of the processing of this query, in the form of a duration. requests The number of requests. list-cache-hits The number of successful list cache lookups. The list cache holds search termlists used to accelerate path expressions and text searches. list-cache-misses The number of unsuccessful list cache lookups. Each unsuccessful list cache lookup was followed by a disk access to load the search termlist into the cache. in-memory-list-hits The number of successful list lookups in in-memory stands. expanded-tree-cache-hits The number of successful expanded tree cache lookups. The expanded tree cache cache holds XML document data in the expanded representation used by the XQuery evaluator. expanded-tree-cache-misses The number of unsuccessful expanded tree cache lookups. Each unsuccessful expanded tree lookup was followed by a compressed tree cache lookup to load the expanded tree into the cache. compressed-tree-cache-hits The number of successful compressed tree cache lookups. The compressed tree cache holds XML document data in the compressed representation stored on disk. compressed-tree-cache-misses The number of unsuccessful compressed tree cache lookups. Each unsuccessful compressed tree cache lookup was followed by a disk access to load the compressed tree into the cache. in-memory-compressed-tree-hits The number of successful compressed tree lookups in in-memory stands. value-cache-hits The number of successful value cache lookups. The value cache is a transient cache that exists only for the duration of one query. It holds typed values, and is used to accelerate the frequent conversion of nodes to typed values. value-cache-misses The number of unsuccessful value cache lookups. Each unsuccessful value cache lookup was followed by a conversion of an XML node to a typed value. regexp-cache-hits The number of successful regular expression cache lookups. The regular expression cache is a transient cache that exists only for the duration of one query. It holds compiled regular expressions, and is used to accelerate the frequent use of regular expressions during the evaluation of a query. regexp-cache-misses The number of unsuccessful regular expression cache lookups. Each unsuccessful regular expression cache lookup was followed by a compilation of a regular expression from source text. link-cache-hits The number of successful link cache lookups. The link cache is a transient cache that exists only for the duration of one query. It holds pointers to expanded trees, and is used to accelerate the frequent dereferencing of link nodes. link-cache-misses The number of unsuccessful link cache lookups. Each unsuccessful link cache lookup was followed by a search for the link target tree. filter-hits The number of successful search filter matches. filter-misses The number of unsuccessful search filter matches. fragments-added The number of XML fragments added to the database by an update. fragments-deleted The number of XML fragments deleted from the database by an update. fs-program-cache-hits The number of module cache hits from the entire program made from modules on the file system. fs-program-cache-misses The number of module cache misses from the entire program made from modules on the file system. db-program-cache-hits The number of module cache hits from the entire program made from modules in a database (may contain library modules from the special Modules directory). db-program-cache-misses The number of module cache misses from the entire program made from modules in a database (may contain library modules from the special Modules directory). env-program-cache-hits The number of module cache hits from the entire program made from ad hoc XSLT stylesheet nodes. env-program-cache-misses The number of module cache misses from the entire program made from ad hoc XSLT stylesheet nodes. fs-main-module-sequence-cache-hits The number of main module cache hits from main modules on the file system. fs-main-module-sequence-cache-misses The number of main module cache misses from main modules on the file system. db-main-module-sequence-cache-hits The number of main module cache hits from main modules in a database. db-main-module-sequence-cache-misses The number of main module cache misses from main modules in a database. fs-library-module-cache-hits The number of library module cache hits from library modules on the file system. fs-library-module-cache-misses The number of library module cache misses from library modules on the file system. db-library-module-cache-hits The number of library module cache hits from library modules from the modules database. db-library-module-cache-misses The number of library module cache misses from library modules from the modules database. Some meters are broken down by fragment root and document URI: fragments A sequence of fragment elements, each containing: root The fragment root name. expanded-tree-cache-hits A count of successful expanded tree cache lookups for this fragment root. expanded-tree-cache-misses A count of unsuccessful expanded tree cache lookups for this fragment root. documents A sequence of document elements, each containing: uri The document URI. expanded-tree-cache-hits A count of successful expanded tree cache lookups for this document URI. expanded-tree-cache-misses A count of unsuccessful expanded tree cache lookups for this document URI. There are also meters that measure the query activity per host. There is a `qm:hosts` element with one `qm:host` child per host that participates in the query. Each `qm:host` element contains meters showing the round-trip-time and round-trip-count for communications between the evaluator host and the host referenced in the `xdmp:query-meters` output. The `qm:hosts` element is empty for a single-node cluster. Certain operations are run concurrently with the timing operations, and if those operations are not actually used in the query, they might not be included in the timings. This occurs for operations like `xdmp:estimate`, `xdmp:exists`, and lexicon calls (for example, `cts:element-values`). If you want to see the total timings that include calls that are not used, you can form some other expression with the results of the calls. For example, if you have an expression that calls `xdmp:estimate` in a `let` expression, you can add 0 to the output, which causes it to be included in the timings (something like `xdmp:estimate($query) + 0`).
Example:
      xdmp:query-meters();
      =>
      <qm:query-meters
       xsi:schemaLocation="http://marklogic.com/xdmp/query-meters
           query-meters.xsd"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:qm="http://marklogic.com/xdmp/query-meters">
        <qm:elapsed-time>PT0.22S</qm:elapsed-time>
        <qm:requests>1</qm:requests>
        <qm:list-cache-hits>0</qm:list-cache-hits>
        <qm:list-cache-misses>0</qm:list-cache-misses>
        <qm:in-memory-list-hits>0</qm:in-memory-list-hits>
        <qm:expanded-tree-cache-hits>0
           </qm:expanded-tree-cache-hits>
        <qm:expanded-tree-cache-misses>0
           </qm:expanded-tree-cache-misses>
        <qm:compressed-tree-cache-hits>0
           </qm:compressed-tree-cache-hits>
        <qm:compressed-tree-cache-misses>0
           </qm:compressed-tree-cache-misses>
        <qm:in-memory-compressed-tree-hits>0
           </qm:in-memory-compressed-tree-hits>
        <qm:value-cache-hits>0</qm:value-cache-hits>
        <qm:value-cache-misses>0</qm:value-cache-misses>
        <qm:regexp-cache-hits>0</qm:regexp-cache-hits>
        <qm:regexp-cache-misses>0</qm:regexp-cache-misses>
        <qm:link-cache-hits>0</qm:link-cache-hits>
        <qm:link-cache-misses>0</qm:link-cache-misses>
        <qm:fragments-added>0</qm:fragments-added>
        <qm:fragments-deleted>0</qm:fragments-deleted>
        <qm:fs-program-cache-hits>1</qm:fs-program-cache-hits>
        <qm:fs-program-cache-misses>0</qm:fs-program-cache-misses>
        <qm:db-program-cache-hits>0</qm:db-program-cache-hits>
        <qm:db-program-cache-misses>0</qm:db-program-cache-misses>
        <qm:env-program-cache-hits>0</qm:env-program-cache-hits>
        <qm:env-program-cache-misses>0</qm:env-program-cache-misses>
        <qm:fs-main-module-sequence-cache-hits>0
           </qm:fs-main-module-sequence-cache-hits>
        <qm:fs-main-module-sequence-cache-misses>0
           </qm:fs-main-module-sequence-cache-misses>
        <qm:db-main-module-sequence-cache-hits>0
           </qm:db-main-module-sequence-cache-hits>
        <qm:db-main-module-sequence-cache-misses>0
           </qm:db-main-module-sequence-cache-misses>
        <qm:fs-library-module-cache-hits>0
           </qm:fs-library-module-cache-hits>
        <qm:fs-library-module-cache-misses>0
           </qm:fs-library-module-cache-misses>
        <qm:db-library-module-cache-hits>0
           </qm:db-library-module-cache-hits>
        <qm:db-library-module-cache-misses>0
           </qm:db-library-module-cache-misses>
        <qm:fragments/>
        <qm:documents/>
        <qm:hosts/>
      </qm:query-meters>
Example:
    xquery version "1.0-ml";
    declare namespace qm="http://marklogic.com/xdmp/query-meters";

    fn:count(collection()),
    xdmp:query-meters()/qm:elapsed-time

    => The count of the number of documents in the database followed by
       the elapsed-time element of the xdmp:query-trace XML output:

    153
    <qm:elapsed-time xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                     xmlns:qm="http://marklogic.com/xdmp/query-meters">
    		 PT0.04S</qm:elapsed-time>
xdmp:query-trace(
| $enabled as xs:boolean
) as empty-sequence()
Summary: Enables or disables tracing of this query. When query tracing is enabled, "info" level messages are logged detailing the search optimizations performed.
Parameters:
$enabled : Specify true to enable query tracing, false to disenable query tracing.
Usage Notes: Search optimizations are performed in three phases: the path analysis phase In this phase a path expression is analyzed to determine whether it can be executed in whole or in part through an optimized search. Each individual component of the path is analyzed to see if it is searchable. The searchablity of each path component is logged. the search constraint gathering phase In this phase, search constraints are gathered from the path expression components. The number of constraints contributed by each path component is logged. the search execution phase In this phase, a search is performed using the gathered constraints. The actual number of fragments selected for filtering is logged.
Example:
      xdmp:query-trace(true())
      => ()
xdmp:request( ) as xs:unsignedLong
Summary: Returns the unique key of the current request.
Example:
      xdmp:request()
       => 18263538320779601865
xdmp:rethrow( ) as empty-sequence()
Summary: Within the catch section of a try-catch expression, re-throw the currently caught error.
Example:
      try {
        xdmp:document-delete($uri)
      } catch ($ex) {
        (: ignore documents that aren't there :)
        if ($ex/error:code eq 'XDMP-DOCNOTFOUND') then ()
        else xdmp:rethrow()
      }
xdmp:schema-database( ) as xs:unsignedLong
Summary: Returns the database ID of the schema database associated with the current database.
Usage Notes: To run queries against the schema database, you can specify the `xdmp:schema-database()` function as the second parameter to `xdmp:eval-in()`.
Example:
      xdmp:schema-database()
      => 15467547981724877000
xdmp:security-database( ) as xs:unsignedLong
Summary: Returns the database ID of the security database associated with the current database.
Usage Notes: To run queries against the security database, you can specify the `xdmp:security-database()` function as the second parameter to `xdmp:eval-in()`.
Example:
      xdmp:security-database()
      => 8447094497219470018
xdmp:server(
| [$name as xs:string]
) as xs:unsignedLong+
Summary: Returns the the ID(s) of the App Server specified in the parameter. Returns the ID of the current App Server if no parameter is specified.
Parameters:
$name (optional): The name of the App Server. The default value is the name of the current App Server.
Example:
      xdmp:server("foo.example.com")
      => 15495681647217162987
xdmp:server-name(
| $id as xs:unsignedLong
) as xs:string
Summary: Return the name of the App Server with the given ID.
Parameters:
$id : A App Server ID.
Example:
    xdmp:server-name(845637403676198)
    => "Docs"
xdmp:servers( ) as xs:unsignedLong*
Summary: Returns a sequence of the IDs of all the App Servers in the system.
Example:
      xdmp:servers()
       => 18263538320779601865
    2760886727871312968
    1551965607977434000
    2714941248661564752
xdmp:subbinary(
| $source as binary(),
| $starting-location as xs:double,
| [$length as xs:double]
) as binary()
Summary: Returns a binary node made up of a subset of the given binary node.
Parameters:
$source : A binary node whose subset will be returned
$starting-location : The new binary node starts at the byte position indicated by starting-location. The first byte is at location 1.
$length (optional): The length in bytes of the new binary node.
Usage Notes: Usage is exactly like fn:substring except that it applies to a binary node rather than a string.
Example:
      data(xdmp:subbinary(binary { xs:hexBinary("DEADBEEF") }, 3, 2))
      => xs:hexBinary("BEEF")
xdmp:trace(
| $name as xs:string,
| $value as item()*
) as empty-sequence()
Summary: Signal a trace event. If trace events are activated and the event is enabled, the trace event is logged.
Parameters:
$name : The trace event name.
$value : The trace event data.
Example:
      xdmp:trace("My Application Event",$my-application-data)
      => ()
xdmp:triggers-database( ) as xs:unsignedLong
Summary: Returns the database ID of the triggers database associated with the current database.
Example:
      xdmp:triggers-database()
      => 8447094497219470018
xdmp:uri-content-type(
| $uri as xs:string
) as xs:string
Summary: Returns the content type of the given URI as matched in the mimetypes configuration. xdmp:content-type continues to work too.
Parameters:
$uri : The document URI.
Example:
      xdmp:uri-content-type("example.txt")
      => text/plain
Example:
      xdmp:uri-content-type("example.xml")
      => text/xml
Example:
      xdmp:uri-content-type("example.doc")
      => application/msword
xdmp:uri-format(
| $uri as xs:string
) as xs:string
Summary: Returns the format of the given URI as matched in the mimetypes configuration.
Parameters:
$uri : The document URI.
Example:
      xdmp:uri-format("example.txt")
      => text
Example:
      xdmp:format("example.xml")
      => xml
xdmp:version( ) as xs:string
Summary: Returns the current MarkLogic Server version.
Example:
      xdmp:version()
       => "4.2-1"

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