SAXONICA

Saxon Documentation
Full Contents
About Saxon
Changes in this Release
Notices
Using XSLT 2.0
Using XQuery
| Introduction
| Running XQuery from the Command Line
| Running Queries from a Java Application
| Using XQuery Update
| Calling XQuery Functions from Java
| Result Format
» | Compiling Queries to Java code
| Extensibility
| Extensions
| Use Cases
Handling Source Documents
XML Schema Processing
XPath API for Java
Saxon on .NET
Extensibility
Saxon Extensions
Sample Saxon Applications
The Saxon SQL Extension
XSLT Elements
XPath 2.0 Expression Syntax
Function Library
Standards Conformance

# Compiling Queries to Java code

Saxon-SA (from release 8.9) provides the capability to compile a query to Java source code. The Java source code can then be compiled to byte code in a class file, which can be executed in the same way as any other Java program.

This is achieved by adding a code-generation phase to the existing query analysis phase. The query analyzer generates an optimized expression tree in memory. In interpreted execution, the run time system evaluates this expression tree directly. With compiled execution, the expression tree is compiled to Java code. The Java code makes calls on the Saxon run-time to perform operations such as navigating the source tree and serializing the output.

The following sections discuss Java code generation in more detail.

- Limitations

- Java Code Generation from the Command Line

- Running Compiled Code from the Command Line

- Running a Compiled Query as a Servlet

- Calling Compiled Queries from an Application

Next