tf:query

Execute an XQuery

Top of page

Related Syntax Constructs

The following construct(s) refer to this construct:


Syntax

tfquery(string $query) => item*

Description

Function tf:query compiles and executes a nested XQuery, that is passed as a string. It returns the result of the query as a sequence of items. Any errors that occur during compilation or execution of the nested query will be reported as execution errors of the calling query.

Parameters

$query

A string that contains an executable query.

Examples

  • The example uses a static query which might just as well been executed directly, but the power of this function is in executing queries that are created during run-time, for example by reading it from somewhere or assembling it from pieces.

    let $query := "for $book in collection('ino:etc')//book
    where $book//last='Buneman'
    return $book"
    return tf:query($query)