Using XQuery

This section describes how to use Saxon as an XQuery processor, either from the command line, or from the Java API.

For details of the .NET API, see Saxon API for .NET.

For information about the conformance of Saxon to the XQuery 1.0, XQuery 3.0 and XQuery 3.1 specifications, and about the handling of implementation-defined features of the specifications, see Conformance.

Saxon uses the same run-time engine to support both XQuery and XSLT, reflecting the fact that the two languages have very similar semantics. Most of the compile-time code (in particular, the type checking logic and the optimizer) is also common. The XQuery support in Saxon consists essentially of an XQuery parser (which is itself an extension of the XPath parser); the parser generates the same internal interpretable code as the XSLT processor. There are also some constructs in the internal expression tree that will only be generated from XQuery source rather than XSLT source; examples are the XQuery order by and group by clauses, which have no direct XSLT equivalent.

The XQuery processor may be invoked either from the operating system command line, or via an API from a user-written application. There is no graphical user interface provided.

Saxon is an in-memory processor. Unless you can take advantage of streaming, Saxon is designed to process source documents that fit in memory. Saxon has been used successfully to process source documents of 100Mbytes or more without streaming, but if you attempt anything this large, you need to be aware (a) that you will need to allocate sufficient memory to the Java VM (at least 5 times the size of the source document), and (b) that complex FLWOR expressions may be very time-consuming to execute. (In this scenario, Saxon-EE is recommended, because it has a more powerful optimizer for complex joins.)

For details of how to set up collation URIs for use in XQuery, see Implementing a Collating Sequence.