eval

Execute a XQuery script sent by the client.

If the expected return value is a single XML document or element, it can be serialized in HTML or XHTML. If the return value is a sequence of items, items can be wrapped in elements describing their type (see format below).

HTTP Request: POST, GET

Parameters:

Name Value Description
query source code of the query.
format case insensitive value, optional ("XML" by default).
  • "items" (data type "text/xml"): a sequence of wrapped items. See format below in 'Response' section.

  • "XML" (data type "text/xml") Assumes the result is a single document/element item: if the query returns more than one node, the result will simply be malformed, but no error is raised.

  • "HTML", "XHTML" (data type "text/html") : Assumes the result is a single HTML document.

mode Execution mode: "profile" to profile the expression, empty otherwise.

Profiling should be used only with format="items".

encoding [optional] a valid encoding name, used for serializing the results. Default is UTF-8.
maxtime [optional] maximum execution time in milliseconds (integer, default is no limit).
counting [optional] counting method for the total number of items (meaningful when format="items").

Note: "estimated" counts documents within a collection, it is significant only when the query returns at most one hit per document; for example collection("/products")//Product[@price > 100]

count [optional] maximum number of items returned (meaningful when format="items").
first [optional] rank of first item returned [meaningful when format="items"].
library Name of Library used (can be empty if exactly one Library in server).

Response:

 mime-type: text/xml or text/html

When using format=items, the returned items are wrapped as follows:

<items>
 <item type="integer">12345</item>
 <item>some text</item>
 <item type="node()"><a><empty/>text</a></item> 
</items>

Note that if several element nodes are returned and format is not items , the result is not a well-formed document.

Error codes:

Compilation
invalid XQuery script.
Evaluation
Error in XQuery execution
TimeOut
Time limit (optional) reached in execution