qtspecs
qtspecs copied to clipboard
New function fn:query()
I propose a new function fn:query()
to perform dynamic XQuery/XPath evaluation: a similar role to fn:transform() and xsl:evaluate.
I propose a design based on the design of fn:invisible-xml() - fn:query should take a query string as its argument, and return a function item that can be called to evaluate the query.
The fn:query() function will need an options map to supply significant aspects of the static context, for example the base URI. But I don't think we need to support everything. Public functions in the calling module should probably be made available automatically, in which case we don't need to support "import module".
The dynamic evaluation function will need an options map to supply significant aspects of the dynamic context, notably the context value and values of external parameters. The query result should be returned in "raw" (ie. unserialized) form.
Perhaps there should be an option language="xpath" to say that the "query" is actually an XPath expression; some implementations might find that easier to support, especially when the processor is itself an XPath processor.
(Motivation: Saxon has a pair of ancient extension functions saxon:compile-query
and saxon:query
and the design needs modernising, and bridging across to additional platforms. We might as well get it into the standard if we're doing that.)