# XQuery 1.0

The change defined by bug 5083 is implemented: namespace URIs declared in a direct element constructor may contain doubled curly braces ("{{" or "}}") to represent single curly braces, and must not contain curly braces unless they are so doubled.

The streaming copy optimization, previously available only with XSLT, is now available also with XQuery. This allows a subset of XQuery expressions to be evaluated in streaming mode, that is, without building the tree representation of the source document in memory. The facility is available only in Saxon-SA. It can be invoked either using the extension function `saxon:stream()` or by means of the pragma `(# saxon:stream #){ expr }`. Use the `-explain` switch on the command line to check whether the optimization is successful.

An additional option `-xsd:schemadoc1.xsd;schemadoc2.xsd...` is available on the command line. This supplies a list of additional schema documents to be loaded. These are not automatically available in the static context of the query, but they are available for use when validating input documents (or result documents). The argument can also be used to supply the schema location of a schema document imported by the query, in the case where the query refers only to the target namespace of the schema and not to its location.

For consistency, the command line now allows the file name containing the query text to be specified using the option `-q:filename`, and an inline query can be specified using `-qs:querytext` (place the option in quotes if the query text contains spaces). The existing convention of specifying the query file as the last option before any query parameters will continue to work.

An additional command line option `-traceout` allows the output from the `trace()` function to be directed to a file, or to be discarded. A corresponding option is available in the API (classes `DynamicQueryContext` and `XQueryEvaluator`).

The native API for XQuery, specifically the `StaticQueryContext` object, now allows external variables to be declared, as an alternative to declaring them in the Query prolog. This facility has not yet been added to S9API, pending user feedback.

The extension `saxon:validate-type` now allows validation of attribute nodes (the expression may be a computed attribute constructor). This was previously accepted in the syntax, but had no effect.

The ability to compile queries into Java source code has been extended, in that some constructs that were not previously supported can now be compiled. Some restrictions remain. One important enhancement is that many calls to Java extension functions can now be compiled. This is particularly beneficial because it means that these calls no longer rely on Java reflection, which gives the opportunity for a substantial performance improvement.

Next