saxon:compile-query
Compiles an XQuery query.
compile-query($query as xs:string) ➔ jt:net.sf.saxon.query.XQueryExpression
Arguments | |||
| $query | xs:string | The query to be compiled |
Result | jt:net.sf.saxon.query.XQueryExpression |
Namespace
http://saxon.sf.net/
Saxon availability
Requires Saxon-PE or Saxon-EE. Available for Java and C/C++ only (not .NET).
Notes on the Saxon implementation
Available since Saxon 9.0. Not available in SaxonCS.
Details
This function takes as input a string containing an XQuery query, and produces as
output a compiled query suitable for use with the saxon:query()
extension
function.
The static context for the query (for example, its namespace bindings and its base URI)
must be defined within its own query prolog. It does not inherit any context values from
the query or stylesheet in which the saxon:compile-query()
function is
called. The query cannot access variables or functions defined in the containing query
or stylesheet.
There are several ways the string containing the query might be constructed. It can be
built directly as a dynamic string in the calling application. In the case of XSLT, it
can be read from a file using the unparsed-text()
function. It can also be
generated by calling saxon:serialize()
on an XML representation of the
query, using the serialization method saxon:xquery.
The compiled query can be evaluated (repeatedly) using the saxon:query()
extension function.