xdmp.invoke( path as String, [vars as Object], [options as Object?] ) as ValueIterator
Returns the result of evaluating a module at the given path.
Parameters | |
---|---|
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.keyFromQName 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 object. The default value is null. See the
xdmp.eval section for a list of options.
|
http://marklogic.com/xdmp/privileges/xdmp-invoke
xdmp.invoke("http://example.com/modules/foo.xqy") => 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/log.sjs" containing the following code: xdmp.log(myvar) Then you can call this module using xdmp.invoke as follows: xdmp.invoke("log.sjs", {myvar: "log this to ErrorLog.txt"}, { modules : xdmp.modulesDatabase(), root : "http://example.com/application/" }); => Invokes a JavaScript module from the modules database with the URI http://example.com/application/log.sjs. The invoked module will then be executed, logging the message sent in the external variable to the ErrorLog.txt log file.
Stack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.