Running Compiled Code from the Command Line

This section does not apply to code generated with the -servlet option.

The generated Java code has a main() method allowing it to be run directly from the command line. This is not the most efficient way of running a query, because of the overhead of starting up the Java runtime; but it is useful when testing, or to execute a long-running "batch" query.

The query is run in the same way as any other Java program:

java query-class [options] [keyword=value]...

Note that the classpath must include saxon8sa.jar as well as the directory in which the Saxon-SA license file is installed.

The options available on the command line are as follows:



-s source-file

XML source file to be assigned to the initial context node


Display timing, version, and progress information

-o output-file

File to hold the serialized output of the query


Apply strict schema validation to input files.


Apply lax schema validation to input files

A keyword=value pair is used to supply the value of an external variable defined in the query prolog. If the variable name is in a namespace, the keyword should use Clark notation, that is "{uri}localname". The value is interpreted as an untypedAtomic value, and will be converted to the required type of the variable using the function conversion rules (for example if the variable start is declared as an integer, then the value can be supplied in the form start=42).

The notation +keyword=filename can be used to initialize an external variable to hold the document node of an XML document identified by the given filename.

The notation !keyword=value can be used to set serialization parameters. For example !indent=yes causes the output to be indented.

Note that there is no option on the command line to load additional schema documents. Schema components that are needed during query execution must be derived either from schema documents that were imported into the query at compile time, or must be referenced using xsi:schemaLocation in a source document.