This page was generated
February  9,  2010
11:52  AM
XQuery Built-In and 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 the IDs of all hosts beloning 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", or "linux").
xdmp:pretty-print Returns a well-formatted XQuery module.
xdmp:product-edition Returns the current Mark Logic 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 Rethrow 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".

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
)  as   xs:unsignedLong*
Summary:

Returns a sequence of forest IDs in the specified database.

Parameters:
$database : A database ID.

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. 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). 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.

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.

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 the IDs of all hosts beloning 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, critcal, 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", or "linux").

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 Mark Logic 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.
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).
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.

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: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: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:

Rethrow the currently caught error.

Example:
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()
   => "3.2-1"