Loading TOC...

MarkLogic 12 Product Documentation
prof:value

prof:value(
   $expr as xs:string,
   [$map as map:map?],
   [$context as item()?],
   [$options as (element()|map:map)?]
) as item()*

Summary

Evaluate an expression in the context of the current evaluating statement and return the profiling report for its evaluation. This differs from prof:eval in that prof:value preserves all of the context from the calling query, so you do not need to re-define namespaces, variables, and so on. Although the expression retains the context from the calling query, it is evaluated in its own transaction.

For details on profiling requests and interpreting the output of a profile request, see Profiling Requests to Evaluate Performance.

Parameters
expr The string representing an expression to evaluate.
map A map of namespace bindings. The keys should be namespace prefixes and the values should be namespace URIs. These namespace bindings will be added to the in-scope namespace bindings in the evaluation of the path.
context Bind the context item to this value during evaluation of the expression.
options Options with which to customize this operation. You can specify options as either an options XML element in the namespace "xdmp:eval", or as a map:map. The option names below are XML localnames. When using a map, replace any hyphens in an option name with camel casing. For example, "an-option" becomes "anOption" when used as a map:map entry key. This function supports the following options:
ignore-amps
Whether or not to evaluate the code without using any Amps from the caller. Allowed values: true, false (default). If this option is set to true, the code is evaluated without using Amps from the caller. For more details, see Temporarily Increasing Privileges with Amps. This option is not usable with dbg:eval.
isolate
Whether or not to evaluate and profile the expression with the calling HTTP request, HTTP response, and session context hidden from the evaluated code. Allowed values: true, false (default). If this option is set to true, the expression runs as if outside of an HTTP App Server: builtins that read the request (e.g. xdmp:get-request-header) or write the response (e.g. xdmp:add-response-header) behave as if called outside of an HTTP context, typically returning the empty sequence. Session-related builtins likewise have no session to read or update; in particular, xdmp:set-session-field returns the set value instead of creating a new session. This option is intended as a defense-in-depth control when profiling user-supplied expressions, and is typically used together with ignore-amps.

Required Privileges

http://marklogic.com/xdmp/privileges/xdmp-value and either http://marklogic.com/xdmp/privileges/profile-my-requests or http://marklogic.com/xdmp/privileges/profile-any-requests

Usage Notes

You can only evaluate and profile expressions with prof:value; no prolog definitions (namespace declarations, function definitions, module imports, and so on) are allowed.

Example

  prof:value("xdmp:random()")
  => (<prof:report>...</prof:report>,9478952250821284456)

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