SAXONICA

Saxon Documentation
Full Contents
About Saxon
Changes in this Release
Conditions of Use
Using XSLT 2.0
Using XQuery
| Introduction
| Running XQuery from the Command Line
| Invoking XQuery using the XQJ API
| Invoking XQuery from an application
| 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.

- 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