eutil:eval(xquery-string,context-item)

The eutil:eval(xquery-string,context-item) function is similar to eutil:eval(xquery-string) except that the evaluation is performed with the context item set to the value of the second argument. The static type of the context item is defined to be "item()". The context item is a value that the XQuery evaluator makes available to the query that can be set by the implementation.

Important: Because xquery-string is compiled on the fly each time eutil:eval() is called, it can be time-consuming. It was designed for development use, and is not supported for production use.
   
Function Signature eutil:eval($xquery-string as xs:string, $context-item as item()) as item()*
Function Summary The eutil:eval(xquery-string,context-item) function is similar to eutil:eval(xquery-string) but in addition sets the context item to the provided item.
Parameters $xquery-query as xs:string, $context-item as item()
Example
eutil:eval("let $item as node() := . treat as node()
return $item/text()", <something>some text</something>)
returns:

"some text"

Errors Thrown
  • endeca-err:EVAL0001 if the input to the function was a library module rather than a main module.
  • endeca-err:EVAL0002 if the input to the function was an updating main module.
  • endeca-err:EXTF0001 if an unexpected internal error of a different nature occurred.

For more details about the errors thrown by external functions, see the topic "Error code listing."

Note The context-item type is item(), so you need a treat expression or something similar to use it as a value with a more specific type.