MarkLogic Server 11.0 Product Documentation
xdmp:function

xdmp:function(
   $function as xs:QName?,
   [$module-path as xs:string?]
) as xdmp:function

Summary

Returns a function value as an xdmp:function type. You can return an xdmp:function from an expression or a function. You can execute the function referred to by an xdmp:function by passing the xdmp:function value to xdmp:apply. If the module-path ends with a file extension matching the ones configured for application/vnd.marklogic-javascript in your MarkLogic Mimetypes configuration, and the function's namespace URI is empty, the module is considered to be JavaScript. In this case, the function parameter can be empty.

Parameters
function The function QName, which includes its local name and namespace. If the function is not found in the current query context or in the module specified in the second parameter, then an exception is thrown when the function is used with xdmp:apply.
module-path The optional path to the module where the function specified in the first parameter is defined. If the module-path is not supplied, the function QName must be in-scope in the query context. If the empty sequence is supplied, the function behaves as if the parameter is not supplied (that is, it uses the in-scope query context).

Example

xquery version "1.0-ml";

xdmp:function(xs:QName("fn:empty"))

Example

xquery version "1.0-ml";

declare namespace admin="http://marklogic.com/xdmp/admin";

xdmp:function(xs:QName("admin:get-configuration"),
      "/MarkLogic/admin.xqy")

Example

xquery version "1.0-ml";

let $function := xdmp:function(xs:QName("fn:concat"))
return
   xdmp:apply($function, "hello", " world")

=> hello world
Powered by MarkLogic Server | Terms of Use | Privacy Policy