Loading TOC...

xdmp:invoke-function

xdmp:invoke-function(
   $func as function(),
   [$options as (element()|map:map)?]
) as item()*

Summary

Returns the result of evaluating an XQuery function value.

Parameters
$func A zero arity function value to execute.
$options Options controlling the evaluation. The default is no options. For detailed option information, see xdmp:invoke for detailed option information. NOTE: Some options require additional privileges; for details, see the Required Privileges section of xdmp:invoke. When expressed as an element, the options node must be in the xdmp:eval namespace.

Required Privileges

Use of this function requires the following privilege:

http://marklogic.com/xdmp/privileges/xdmp-invoke

Some options require additional privileges. For details, see the Required Privileges for xdmp:invoke.

Usage Notes

The XQuery version of this function (xdmp:invoke-function) can only be used to invoke XQuery functions. The Server-Side JavaScript version of this function (xdmp.invokeFunction) can only be used to invoke JavaScript functions.

Example

  xquery version "1.0-ml";
  let $content := <doc/>
  return
    xdmp:invoke-function(
      function() { xdmp:document-insert("doc",$content) },
      <options xmlns="xdmp:eval">
        <transaction-mode>update-auto-commit</transaction-mode>
      </options>)
	
  (: Invokes the function value in an update-auto-commit transaction. :)

Example

  xquery version "1.0-ml";
  let $content := <doc/>
  return
    xdmp:invoke-function(
      function() { xdmp:document-insert("doc",$content), xdmp:commit() },
      <options xmlns="xdmp:eval">
        <transaction-mode>update</transaction-mode>
      </options>)
	
  (: Invokes the function value in a multi-statement update transaction. :)

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

Comments

The commenting feature on this page is enabled by a third party. Comments posted to this page are publicly visible.
  • The first parameter, the function item, is called `$path`. Not really a bug, but not the best naming convention ;-)