<apidoc:module name="ProfileBuiltins" category="ProfileBuiltins" lib="prof" xmlns:apidoc="http://marklogic.com/xdmp/apidoc"><apidoc:summary access="public">
<p xmlns="http://www.w3.org/1999/xhtml">Implements a library of functions which allow developers to profile
evaluation of XQuery programs. An XQuery program is defined as an XQuery
main module, fully expanded with any XQuery library modules needed for its 
evaluation.</p>
<p xmlns="http://www.w3.org/1999/xhtml">To profile an XQuery program, set the <code>profile allow</code> option 
to <code>true</code> in the App Server or task server in which
the request is serviced.  If you request a profile report for an XQuery
program whose App Server does not have profiling enabled (and if 
<code>prof:enable</code> is not called before generating the profile 
report), then the profile APIs do not profile the request, and the APIs 
that generate the report return the empty sequence.</p>
<p xmlns="http://www.w3.org/1999/xhtml">The profile functions use the <code>prof:</code> namespace prefix, which is
predefined in the server.</p>
</apidoc:summary><apidoc:function name="enable" type="builtin" lib="prof" category="ProfileBuiltins" hidden="false" bucket="MarkLogic Built-In Functions">
    <apidoc:summary>
  <p xmlns="http://www.w3.org/1999/xhtml">Enable profiling for this request.  Profiling may be
  enabled or disabled as often as you like.  Enabling while
  a request is enabled has no effect.</p>
  <p xmlns="http://www.w3.org/1999/xhtml">If profiling is not allowed for the App Server, this function 
  does nothing.</p>
<p xmlns="http://www.w3.org/1999/xhtml">
  Note that profiling does not cross eval/invoke boundaries.  If the
  request being profiled calls xdmp:eval or xdmp:invoke, the individual
  expressions in that code will not be profiled.  The overall time taken
  by the called code will appear as a single call in the caller's
  profiling report.
</p>
</apidoc:summary>
    <apidoc:params>
      <apidoc:param name="request-id" type="xs:unsignedLong" optional="false">
    A request ID. Use the <code xmlns="http://www.w3.org/1999/xhtml">xdmp:request()</code> function, which 
    returns the request ID for the currently running request, to specify
    the current request.
  </apidoc:param>
    </apidoc:params>
    <apidoc:privilege>
  <p xmlns="http://www.w3.org/1999/xhtml">Either 
  <code>http://marklogic.com/xdmp/privileges/profile-my-requests</code> or
  <code>http://marklogic.com/xdmp/privileges/profile-any-requests</code>
  is required for profiling requests other than the current request, with
  the <code>profile-my-requests</code> privilege allowing profiling of 
  requests issued by the same user ID, and the 
  <code>profile-any-requests</code> privilege allowing profiling of requests
  issued by any user ID. No privilege is required to profile the currently 
  running request (that is, self-profiling is always allowed).</p>
</apidoc:privilege>
    <apidoc:return>empty-sequence()</apidoc:return>
    <apidoc:example><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
  prof:enable(xdmp:request())
  =&gt; ()
  </pre>
</apidoc:example>
  </apidoc:function><apidoc:function name="disable" type="builtin" lib="prof" category="ProfileBuiltins" hidden="false" bucket="MarkLogic Built-In Functions">
    <apidoc:summary>
  Disable profiling for this request.  Profiling may be
  enabled or disabled as often as you like.  Disabling does
  not clear accumulated profiling statistics.  Disabling while
  disabled has no effect.
  If profiling is not allowed for the App Server, this function does nothing.
</apidoc:summary>
    <apidoc:params>
      <apidoc:param name="request-id" type="xs:unsignedLong" optional="false">
    A request ID. Use the <code xmlns="http://www.w3.org/1999/xhtml">xdmp:request()</code> function, which 
    returns the request ID for the currently running request, to specify
    the current request.
  </apidoc:param>
    </apidoc:params>
    <apidoc:privilege>
  <p xmlns="http://www.w3.org/1999/xhtml">Either 
  <code>http://marklogic.com/xdmp/privileges/profile-my-requests</code> or
  <code>http://marklogic.com/xdmp/privileges/profile-any-requests</code>
  is required for profiling requests other than the current request, with
  the <code>profile-my-requests</code> privilege allowing profiling of 
  requests issued by the same user ID, and the 
  <code>profile-any-requests</code> privilege allowing profiling of requests
  issued by any user ID. No privilege is required to profile the currently 
  running request (that is, self-profiling is always allowed).</p>
</apidoc:privilege>
    <apidoc:return>empty-sequence()</apidoc:return>
    <apidoc:usage>
 <p xmlns="http://www.w3.org/1999/xhtml">Any expressions evaluated after <code>prof:disable</code> is called 
 (but before <code>prof:enable</code> is called again) will
 not be profiled and will not appear in the profile report.</p>
</apidoc:usage>
    <apidoc:example><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
  prof:disable(xdmp:request())
  =&gt; ()
  </pre>
</apidoc:example>
    <apidoc:example><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
prof:enable(xdmp:request()),
fn:concat("hello", " world"),
prof:disable(xdmp:request()),
fn:current-dateTime(),
prof:report(xdmp:request())

  =&gt; A profile report that does not include
     the call to fn:current-dateTime().
  </pre>
</apidoc:example>
  </apidoc:function><apidoc:function name="reset" type="builtin" lib="prof" category="ProfileBuiltins" hidden="false" bucket="MarkLogic Built-In Functions">
    <apidoc:summary>
  Clear any accumulated profiling statistics for the requests.
  If profiling has never been started for the request, nothing is done.
  If profiling is not allowed for the App Server, this function does nothing.
</apidoc:summary>
    <apidoc:params>
      <apidoc:param name="request-id" type="xs:unsignedLong" optional="false">
    A request ID. Use the <code xmlns="http://www.w3.org/1999/xhtml">xdmp:request()</code> function, which 
    returns the request ID for the currently running request, to specify
    the current request.
  </apidoc:param>
    </apidoc:params>
    <apidoc:privilege>
  <p xmlns="http://www.w3.org/1999/xhtml">Either 
  <code>http://marklogic.com/xdmp/privileges/profile-my-requests</code> or
  <code>http://marklogic.com/xdmp/privileges/profile-any-requests</code>
  is required for profiling requests other than the current request, with
  the <code>profile-my-requests</code> privilege allowing profiling of 
  requests issued by the same user ID, and the 
  <code>profile-any-requests</code> privilege allowing profiling of requests
  issued by any user ID. No privilege is required to profile the currently 
  running request (that is, self-profiling is always allowed).</p>
</apidoc:privilege>
    <apidoc:return>empty-sequence()</apidoc:return>
    <apidoc:example><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
  prof:reset(xdmp:request())
  =&gt; ()
  </pre>
</apidoc:example>
  </apidoc:function><apidoc:function name="report" type="builtin" lib="prof" category="ProfileBuiltins" hidden="false" bucket="MarkLogic Built-In Functions">
    <apidoc:summary>
  Return a <code xmlns="http://www.w3.org/1999/xhtml">prof:report</code> node containing the current state of
  profiling statistics for the given request.  If profiling
  has never been enabled for the request, the empty sequence
  is returned.
  If profiling is not allowed for the App Server, this function
  returns an empty sequence.
</apidoc:summary>
    <apidoc:params>
      <apidoc:param name="request-id" type="xs:unsignedLong" optional="false">
    A request ID. Use the <code xmlns="http://www.w3.org/1999/xhtml">xdmp:request()</code> function, which 
    returns the request ID for the currently running request, to specify
    the current request.
  </apidoc:param>
    </apidoc:params>
    <apidoc:privilege>
  <p xmlns="http://www.w3.org/1999/xhtml">Either 
  <code>http://marklogic.com/xdmp/privileges/profile-my-requests</code> or
  <code>http://marklogic.com/xdmp/privileges/profile-any-requests</code>
  is required for profiling requests other than the current request, with
  the <code>profile-my-requests</code> privilege allowing profiling of 
  requests issued by the same user ID, and the 
  <code>profile-any-requests</code> privilege allowing profiling of requests
  issued by any user ID. No privilege is required to profile the currently 
  running request (that is, self-profiling is always allowed).</p>
</apidoc:privilege>
    <apidoc:return>element(prof:report)?</apidoc:return>
    <apidoc:example><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
(: Before running this, make sure profiling is enabled 
   on the App Server :)
prof:enable(xdmp:request()),
fn:current-dateTime(),
prof:report(xdmp:request())
=&gt;

2007-02-16T19:24:30.093-08:00
&lt;prof:report xsi:schemaLocation="http://marklogic.com/xdmp/profile 
   profile.xsd" 
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
   xmlns:prof="http://marklogic.com/xdmp/profile"&gt;
  &lt;prof:metadata&gt;
    &lt;prof:overall-elapsed&gt;PT0S&lt;/prof:overall-elapsed&gt;
    &lt;prof:created&gt;2007-02-16T19:24:30.093-08:00&lt;/prof:created&gt;
    &lt;prof:server-version&gt;3.2-20070214&lt;/prof:server-version&gt;
  &lt;/prof:metadata&gt;
  &lt;prof:histogram&gt;
    &lt;prof:expression&gt;
      &lt;prof:expr-id&gt;11698068205613195480&lt;/prof:expr-id&gt;
      &lt;prof:expr-source&gt;prof:report(xdmp:request())&lt;/prof:expr-source&gt;
      &lt;prof:uri/&gt;
      &lt;prof:line&gt;3&lt;/prof:line&gt;
      &lt;prof:count&gt;0&lt;/prof:count&gt;
      &lt;prof:shallow-time&gt;PT0S&lt;/prof:shallow-time&gt;
      &lt;prof:deep-time&gt;PT0S&lt;/prof:deep-time&gt;
    &lt;/prof:expression&gt;
    &lt;prof:expression&gt;
      &lt;prof:expr-id&gt;6277409173981051716&lt;/prof:expr-id&gt;
      &lt;prof:expr-source&gt;xdmp:request()&lt;/prof:expr-source&gt;
      &lt;prof:uri/&gt;
      &lt;prof:line&gt;3&lt;/prof:line&gt;
      &lt;prof:count&gt;1&lt;/prof:count&gt;
      &lt;prof:shallow-time&gt;PT0S&lt;/prof:shallow-time&gt;
      &lt;prof:deep-time&gt;PT0S&lt;/prof:deep-time&gt;
    &lt;/prof:expression&gt;
    &lt;prof:expression&gt;
      &lt;prof:expr-id&gt;13716364291188563274&lt;/prof:expr-id&gt;
      &lt;prof:expr-source&gt;current-dateTime()&lt;/prof:expr-source&gt;
      &lt;prof:uri/&gt;
      &lt;prof:line&gt;2&lt;/prof:line&gt;
      &lt;prof:count&gt;1&lt;/prof:count&gt;
      &lt;prof:shallow-time&gt;PT0S&lt;/prof:shallow-time&gt;
      &lt;prof:deep-time&gt;PT0S&lt;/prof:deep-time&gt;
    &lt;/prof:expression&gt;
    &lt;prof:expression&gt;
      &lt;prof:expr-id&gt;6174150852679522465&lt;/prof:expr-id&gt;
      &lt;prof:expr-source&gt;prof:enable(xdmp:request())&lt;/prof:expr-source&gt;
      &lt;prof:uri/&gt;
      &lt;prof:line&gt;1&lt;/prof:line&gt;
      &lt;prof:count&gt;1&lt;/prof:count&gt;
      &lt;prof:shallow-time&gt;PT0S&lt;/prof:shallow-time&gt;
      &lt;prof:deep-time&gt;PT0S&lt;/prof:deep-time&gt;
    &lt;/prof:expression&gt;
  &lt;/prof:histogram&gt;
&lt;/prof:report&gt;

  </pre>
</apidoc:example>
  </apidoc:function><apidoc:function name="allowed" type="builtin" lib="prof" category="ProfileBuiltins" hidden="false" bucket="MarkLogic Built-In Functions">
    <apidoc:summary>
  <p xmlns="http://www.w3.org/1999/xhtml">
  Returns the value of the Profile Allow setting for the
  App Server or Task Server upon which the target request
  is running.  This function is useful to determine if subsequent
  calls to profiling functions will be effective.
  </p>
  
</apidoc:summary>
    <apidoc:params>
      <apidoc:param name="request-id" type="xs:unsignedLong" optional="false">
    A request ID.
</apidoc:param>
    </apidoc:params>
    <apidoc:privilege>
  <p xmlns="http://www.w3.org/1999/xhtml">Either 
  <code>http://marklogic.com/xdmp/privileges/profile-my-requests</code> or
  <code>http://marklogic.com/xdmp/privileges/profile-any-requests</code>
  is required for profiling requests other than the current request, with
  the <code>profile-my-requests</code> privilege allowing profiling of 
  requests issued by the same user ID, and the 
  <code>profile-any-requests</code> privilege allowing profiling of requests
  issued by any user ID. No privilege is required to profile the currently 
  running request (that is, self-profiling is always allowed).</p>
</apidoc:privilege>
    <apidoc:return>xs:boolean</apidoc:return>
    <apidoc:usage>
 <p xmlns="http://www.w3.org/1999/xhtml">
 Use this function to determine if profiling is allowed on the 
 App Server that owns the target request.  This will indicate
 whether the other profiling functions will be effective.
 </p>
 <p xmlns="http://www.w3.org/1999/xhtml">
  If the Profile Allow setting is off on the App Server, then calls to 
  profiling functions do nothing and return the empty sequence.  You can use 
  <code>prof:allow</code> to test if profiling is allowed on the App Server,
  and if it is then use the other profiling APIs to profile other requests
  or to call <code>prof:eval</code> or <code>prof:invoke</code>; 
  if it is not allowed,
  then your code does not call them.  This type of logic allows you to 
  keep profiling code in your XQuery code and it will only be executed if 
  profiling is allowed in the context in which the code is run, thus 
  allowing you to globally (at the App Server level) switch off 
  profiling without breaking any code.
  </p>
  <p xmlns="http://www.w3.org/1999/xhtml">
  Appropriate privileges are required to call this function,
  as with the other profiling functions.  The return value is
  the state of the App Server Profile Allow setting.  This
  function does not verify that the target request is stopped
  for debugging, which is required for one request to profile another.
  </p>
</apidoc:usage>
    <apidoc:example><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
  prof:allowed(xdmp:request())
  =&gt; true
  </pre>
</apidoc:example>
    <apidoc:example><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
let $profallowed := prof:allowed(xdmp:request())
return 
(
  if ( $profallowed )
  then ( prof:eval('fn:current-dateTime()') )
  else ( ),
  "your code here"
)
  
  =&gt; The profile report (only if profiling is enabled 
     on the App Server) followed by the output of your code.
  </pre>
</apidoc:example>
  </apidoc:function><apidoc:function name="eval" type="builtin" lib="prof" category="ProfileBuiltins" hidden="false" bucket="MarkLogic Built-In Functions">
    <apidoc:summary>
<p xmlns="http://www.w3.org/1999/xhtml">
  Evaluate a string as an XQuery for profiling.  A <code>prof:report</code> node
  will be prepended to any output produced by evaluating the string.
  If profiling is not allowed for the App Server, this function will
  throw a <code>PROF-PROFILEALLOW</code> exception.
</p>
<p xmlns="http://www.w3.org/1999/xhtml">
  Note that profiling does not cross eval/invoke boundaries.  If the
  request being profiled calls xdmp:eval or xdmp:invoke, the individual
  expressions in that code will not be profiled.  The overall time taken
  by the called code will appear as a single call in the caller's
  profiling report.
</p>
</apidoc:summary>
    <apidoc:params>
      <apidoc:param name="xquery" type="xs:string" optional="false">
    The XQuery string to be evaluated.  If the XQuery string contains
    double quotes ("), surround the string with single quotes (').
  </apidoc:param>
      <apidoc:param name="vars" type="item()*" optional="true">
    The external variable values for this evaluation.
    This must be a sequence of even length, alternating QNames and items.
    Each QName and item pair specify a variable name and value.
  </apidoc:param>
      <apidoc:param name="options" type="node()?" optional="true">
    The options node, as for <code xmlns="http://www.w3.org/1999/xhtml">xdmp:eval</code>.  Must be in the 
    <code xmlns="http://www.w3.org/1999/xhtml">xdmp:eval</code> namespace.
  </apidoc:param>
    </apidoc:params>
    <apidoc:privilege>
  <p xmlns="http://www.w3.org/1999/xhtml">Either 
  <code>http://marklogic.com/xdmp/privileges/profile-my-requests</code> or
  <code>http://marklogic.com/xdmp/privileges/profile-any-requests</code>
  is required for <code>prof:eval</code> (the <code>profile-my-requests</code> 
  privilege is suffient because the resulting request is always run by
  the same user who initiated the call, but the 
  <code>profile-any-requests</code> privilege will also work). </p>
</apidoc:privilege>
    <apidoc:return>item()*</apidoc:return>
    <apidoc:example><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
  prof:eval("xdmp:random()")
  =&gt; (&lt;prof:report&gt;...&lt;/prof:report&gt;,9478952250821284456)
  </pre>
</apidoc:example>
  </apidoc:function><apidoc:function name="invoke" type="builtin" lib="prof" category="ProfileBuiltins" hidden="false" bucket="MarkLogic Built-In Functions">
    <apidoc:summary>
<p xmlns="http://www.w3.org/1999/xhtml">
  Profiles and returns the result of evaluating a module at the given path.
  Any result produced by the evaluation will be prepended with a
  <code>prof:report</code> node containing timing and count information 
  about the evaluation.
  If profiling is not allowed for the App Server, this function will
  throw a <code>PROF-PROFILEALLOW</code> exception.
</p>
<p xmlns="http://www.w3.org/1999/xhtml">
  Note that profiling does not cross eval/invoke boundaries.  If the
  request being profiled calls xdmp:eval or xdmp:invoke, the individual
  expressions in that code will not be profiled.  The overall time taken
  by the called code will appear as a single call in the caller's
  profiling report.
</p>
</apidoc:summary>
    <apidoc:params>
      <apidoc:param name="path" type="xs:string" optional="false">
    The path of the module to be executed.  The path is resolved against
    the root of the App Server evaluating the query.  The path must 
    resolve to a main module (not a library module).
  </apidoc:param>
      <apidoc:param name="vars" type="item()*" optional="true">
    The external variable values for this evaluation.
    This must be a sequence of even length, alternating QNames and items.
    Each QName and item pair specify a variable name and value.
  </apidoc:param>
      <apidoc:param name="options" type="node()?" optional="true">
  The options node. The default value is (). The node must be in the 
  <code xmlns="http://www.w3.org/1999/xhtml">xdmp:eval</code> namespace.  See the 
  <code xmlns="http://www.w3.org/1999/xhtml">xdmp:eval</code> section for a list of options.
  </apidoc:param>
    </apidoc:params>
    <apidoc:return>item()*</apidoc:return>
    <apidoc:privilege>
  <p xmlns="http://www.w3.org/1999/xhtml">Either 
  <code>http://marklogic.com/xdmp/privileges/profile-my-requests</code> or
  <code>http://marklogic.com/xdmp/privileges/profile-any-requests</code>
  is required for <code>prof:invoke</code> (the 
  <code>profile-my-requests</code> privilege is suffient because the 
  resulting request is always run by the same user who initiated the call, 
  but the <code>profile-any-requests</code> privilege will also work). </p>
</apidoc:privilege>
    <apidoc:example><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
  prof:invoke("http://example.com/modules/foo.xqy")
  =&gt; (&lt;prof:report&gt;...&lt;/prof:report&gt;,42)</pre>
</apidoc:example>
    <algorithm xmlns="http://www.w3.org/1999/xhtml"></algorithm>
  </apidoc:function><apidoc:function name="value" type="builtin" lib="prof" category="ProfileBuiltins" hidden="false" bucket="MarkLogic Built-In Functions">
    <apidoc:summary>
  Evaluate an expression in the context of the current evaluating 
  statement and return the profiling report for its evaluation. 
  This differs from <code xmlns="http://www.w3.org/1999/xhtml">prof:eval</code> in that <code xmlns="http://www.w3.org/1999/xhtml">prof:value</code>
  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.
</apidoc:summary>
    <apidoc:params>
      <apidoc:param name="expr" type="xs:string" optional="false">
    The string representing an expression to evaluate.
  </apidoc:param>
    </apidoc:params>
    <apidoc:usage>
  <p xmlns="http://www.w3.org/1999/xhtml">You can only evaluate and profile expressions with 
  <code>prof:value</code>; no 
  prolog definitions (namespace declarations, function definitions, 
  module imports, and so on) are allowed.</p>
</apidoc:usage>
    <apidoc:privilege>
  <p xmlns="http://www.w3.org/1999/xhtml">Either 
  <code>http://marklogic.com/xdmp/privileges/profile-my-requests</code> or
  <code>http://marklogic.com/xdmp/privileges/profile-any-requests</code>
  is required for <code>prof:invoke</code> (the 
  <code>profile-my-requests</code> privilege is suffient because the 
  resulting request is always run by the same user who initiated the call, 
  but the <code>profile-any-requests</code> privilege will also work). </p>
</apidoc:privilege>
    <apidoc:return>item()*</apidoc:return>
    <apidoc:example><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
  prof:value("xdmp:random()")
  =&gt; (&lt;prof:report&gt;...&lt;/prof:report&gt;,9478952250821284456)</pre>
</apidoc:example>
  </apidoc:function><apidoc:function name="xslt-eval" type="builtin" lib="prof" category="ProfileBuiltins" hidden="false" bucket="MarkLogic Built-In Functions">
    <apidoc:summary>
<p xmlns="http://www.w3.org/1999/xhtml">
  Evaluate a string as an XSLT stylesheet for profiling.  
  A <code>prof:report</code> node
  will be prepended to any output produced by evaluating the string.
  If profiling is not allowed for the App Server, this function will
  throw a <code>PROF-PROFILEALLOW</code> exception.
</p>
<p xmlns="http://www.w3.org/1999/xhtml">
  Note that profiling does not cross eval/invoke boundaries.  If the
  request being profiled calls xdmp:eval or xdmp:invoke, the individual
  expressions in that code will not be profiled.  The overall time taken
  by the called code will appear as a single call in the caller's
  profiling report.
</p>
</apidoc:summary>
    <apidoc:params>
      <apidoc:param name="stylesheet" type="element()" optional="false">
    The stylesheet to be executed.
  </apidoc:param>
      <apidoc:param name="input" type="node()?" optional="false">
    The context node to which the stylesheet is applied.
  </apidoc:param>
      <apidoc:param name="params" type="map:map?" optional="true">
    The stylesheet parameter values for this evaluation.
    Each key in the map is a string representing the name of the parameter
    in Clark notation: "{namespaceURI}localname". Each entry in the map is
    the value of the corresponding parameter.
  </apidoc:param>
      <apidoc:param name="options" type="node()?" optional="true">
  The options node. The default value is (). The node must be in the 
  <code xmlns="http://www.w3.org/1999/xhtml">xdmp:eval</code> namespace.  See the 
  <a href="#xdmp:eval" xmlns="http://www.w3.org/1999/xhtml"><code>xdmp:eval</code></a> section for a list of options.
  Additional options include:
  <dl xmlns="http://www.w3.org/1999/xhtml">
  <dt><p>&lt;mode&gt;</p></dt><dd>The initial stylesheet mode to use.</dd>
  <dt><p>&lt;template&gt;</p></dt><dd>The name of the initial template
  to apply.</dd>
  </dl>
  </apidoc:param>
    </apidoc:params>
    <apidoc:privilege>
  <p xmlns="http://www.w3.org/1999/xhtml">Either 
  <code>http://marklogic.com/xdmp/privileges/profile-my-requests</code> or
  <code>http://marklogic.com/xdmp/privileges/profile-any-requests</code>
  is required for <code>prof:eval</code> (the <code>profile-my-requests</code> 
  privilege is suffient because the resulting request is always run by
  the same user who initiated the call, but the 
  <code>profile-any-requests</code> privilege will also work). </p>
</apidoc:privilege>
    <apidoc:return>item()*</apidoc:return>
  </apidoc:function><apidoc:function name="xslt-invoke" type="builtin" lib="prof" category="ProfileBuiltins" hidden="false" bucket="MarkLogic Built-In Functions">
    <apidoc:summary>
<p xmlns="http://www.w3.org/1999/xhtml">
  Profiles and returns the result of evaluating an XSLT stylesheet at 
  the given path.
  Any result produced by the evaluation will be prepended with a
  <code>prof:report</code> node containing timing and count information 
  about the evaluation.
  If profiling is not allowed for the App Server, this function will
  throw a <code>PROF-PROFILEALLOW</code> exception.
</p>
<p xmlns="http://www.w3.org/1999/xhtml">
  Note that profiling does not cross eval/invoke boundaries.  If the
  request being profiled calls xdmp:eval or xdmp:invoke, the individual
  expressions in that code will not be profiled.  The overall time taken
  by the called code will appear as a single call in the caller's
  profiling report.
</p>
</apidoc:summary>
    <apidoc:params>
      <apidoc:param name="path" type="xs:string" optional="false">
    The path of the stylesheet to be executed.  The path is resolved against
    the root of the App Server evaluating the query, the Modules directory,
    or relative to the calling module.  For details on resolving paths,
    see "Importing XQuery Modules and Resolving Paths" in the 
    <em xmlns="http://www.w3.org/1999/xhtml">Developer's Guide</em>. 
  </apidoc:param>
      <apidoc:param name="input" type="node()?" optional="false">
    The context node to which the stylesheet is applied.
  </apidoc:param>
      <apidoc:param name="params" type="map:map?" optional="true">
    The stylesheet parameter values for this evaluation.
    Each key in the map is a string representing the name of the parameter
    in Clark notation: "{namespaceURI}localname". Each entry in the map is
    the value of the corresponding parameter.
  </apidoc:param>
      <apidoc:param name="options" type="node()?" optional="true">
  The options node. The default value is (). The node must be in the 
  <code xmlns="http://www.w3.org/1999/xhtml">xdmp:eval</code> namespace.  See the 
  <a href="#xdmp:eval" xmlns="http://www.w3.org/1999/xhtml"><code>xdmp:eval</code></a> section for a list of options.
  Additional options include:
  <dl xmlns="http://www.w3.org/1999/xhtml">
  <dt><p>&lt;mode&gt;</p></dt><dd>The initial stylesheet mode to use.</dd>
  <dt><p>&lt;template&gt;</p></dt><dd>The name of the initial template
  to apply.</dd>
  </dl>
  </apidoc:param>
    </apidoc:params>
    <apidoc:privilege>
  <p xmlns="http://www.w3.org/1999/xhtml">Either 
  <code>http://marklogic.com/xdmp/privileges/profile-my-requests</code> or
  <code>http://marklogic.com/xdmp/privileges/profile-any-requests</code>
  is required for <code>prof:invoke</code> (the 
  <code>profile-my-requests</code> privilege is suffient because the 
  resulting request is always run by the same user who initiated the call, 
  but the <code>profile-any-requests</code> privilege will also work). </p>
</apidoc:privilege>
    <apidoc:return>item()*</apidoc:return>
    <apidoc:usage>
</apidoc:usage>
    <apidoc:example><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
</pre></apidoc:example>
    <algorithm xmlns="http://www.w3.org/1999/xhtml"></algorithm>
  </apidoc:function></apidoc:module>