Loading TOC...

MarkLogic 12 EA 1 Product Documentation
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">
        <update>auto</update>
        <commit>auto</commit>
      </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">
        <update>true</update>
        <commit>explicit</commit>
      </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.