Loading TOC...


   $path as xs:string,
   [$vars as item()*],
   [$options as (element()|map:map)?]
) as item()*


Returns the result of evaluating a module at the given path.

$path The path of the module to be executed as a string. The path is resolved against the root of the App Server evaluating the query, the Modules directory, or relative to the calling module. The module is considered to be JavaScript if the module path ends with a file extension matching the ones configured for application/vnd.marklogic-javascript in MarkLogic's Mimetypes configuration. For details on resolving paths, see "Importing XQuery Modules and Resolving Paths" in the Application Developer's Guide.
$vars The external variable values for this evaluation. This can either be a sequence of map:map objects, or a sequence of even length, alternating QNames and items.

Each key in the map(s) is a string representing the name of the parameter in Clark notation: "{namespaceURI}localname". The function xdmp:key-from-QName is a convenient way to generate these keys. Each entry in the map is the value of the corresponding external variable.

Alternatively, the alternating sequence should contain QName and item pairs that specify a variable name and value for an external variable.

$options The options node. The default value is (). The node must be in the xdmp:eval namespace. See the xdmp:eval section for a list of options.

Required Privileges



  => 2


  This example invokes a module using external variables.
  Assume you have a module in the modules database with a URI
  "http://example.com/application/module.xqy" containing the
  following code:

  xquery version "1.0-ml";
  declare namespace my="my-namespace-uri";
  declare variable $my:var as xs:string external;

  Then you can call this module using xdmp:invoke as follows:

  xquery version "1.0-ml";
  declare namespace my="my-namespace-uri";
        (xs:QName("my:var"), "log this"),
        <options xmlns="xdmp:eval">
  => Invokes an XQuery module from the modules database
     with the URI http://example.com/application/module.xqy.
     The invoked module will then be executed, logging the
     message sent in the external variable to the log. 

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.


  • Please provide any other ways to call java script functions from xquery file.
  • how to call java script functions from xquery file using xdmp:invoke function. I am using ML 7.x version.