XML technologies / XSLT / XSLT 2.0 processors / Saxon 9 / Command-line options
(Excerpt from “XSLT 2.0 & XPath 2.0” by Frank Bongers)
Saxon supports options placed immediately after the program invocation. Several switches may be combined in any order. Some require an additional value such as a filename, a template name or a class identifier.
Setting options in Kernow
Some parameters below are also available in Saxon’s Java GUI Kernow through Configuration > Saxon settings. Where available, the right column notes this. Kernow still uses Saxon 8.9, so options introduced in Saxon 9 are not yet available there.
The following alphabetical list matches Saxon’s command-line output with option -? (see figure: Invoking Saxon 9.0 from the command line with option -?). Saxon 9 extended the options and partly changed their syntax. Earlier spellings and options are also shown; some remain supported for backwards compatibility.
These options apply under Java and .NET to both Saxon-SA and Saxon-B, except XML Schema options, which affect only Saxon-SA and are ignored by Saxon-B.
-a
Option | Purpose | Kernow |
|---|---|---|
| Stylesheet from PI | no |
Processing control:
With option -a, a stylesheet PI in the source identifies the stylesheet. Do not name a stylesheet file: option -xsl must not be set.
-c:filename
Option | Purpose | Kernow |
|---|---|---|
| Compiled stylesheet file | no |
Processing control:
Option -c makes the stylesheet argument identify a compiled stylesheet file whose filename follows. Precompilation can greatly accelerate complex transformations, though gains depend on source size. Creating and using compiled stylesheet files are explained on the next page.
Note: Do not use option -xsl:filename in this context.
-cr:classname (formerly: cr classname)
Option | Purpose | Kernow |
|---|---|---|
| Resolving URI strings | no |
Processing control:
Supplies a Java class name for resolving URI strings passed as collections through function collection(). The user-defined class must implement interface net.sf.saxon.CollectionURIResolver.
-dtd:(on|off)
Option | Purpose | Kernow |
|---|---|---|
| Enable DTD validation | no |
| Disable DTD validation | no |
Processing control:
Enables or disables DTD validation of the source and all resources included through document().
-ds | -dt (deprecated)
Option | Purpose | Kernow |
|---|---|---|
| Standard tree mode | yes, alternatively |
| TinyTree mode (default) | yes, alternatively |
Processing control:
Option -ds switches Saxon to the traditional tree model (linked tree). Alternatively, option -dt explicitly selects the TinyTree model, Saxon’s default.
Note: Saxon 9 retains these only for compatibility; they may disappear. Use -tree:tiny instead of -dt and -tree:linked instead of -ds.
-expand:(on|off)
Option | Purpose | Kernow |
|---|---|---|
| Expand default values | no |
| Do not expand default values | no |
Processing control:
With -expand:off, this suppresses insertion of fixed (fixed) and default values defined by a schema or DTD. Its effectiveness depends on the XML parser. With -expand:on, expansion of fixed and default values is explicitly allowed, the normal behavior.
-explain[:filename]
Option | Purpose | Kernow |
|---|---|---|
| Output stylesheet as a tree | no |
Debugging:
To assist debugging, this outputs all instructions and XPath expressions as an XML tree after optimization. The optional filename receives the output. Without it, option -explain writes to standard error (stderr).
-ext:(on|off)
Option | Purpose | Kernow |
|---|---|---|
| Allow extension functions | no |
| Disable extension function calls | no |
Security:
Replaces deprecated option -noext.
With argument -ext:off, extension function calls are suppressed except Saxon’s own and EXSLT functions.
This primarily protects against untrusted stylesheets, for example fetched over HTTP. Such a stylesheet could otherwise call a Java class through an extension function and gain privileged access to system resources.
Argument -ext:on permits all extensions, the processor’s default behavior.
-im:modename (formerly: -im modename)
Option | Purpose | Kernow |
|---|---|---|
| Select initial mode | yes |
Processing control:
Selects an initial mode (initial mode) for processing. Supply its name. If it has a namespace, supply the expanded form: {uri}localname
-it:template (formerly: -it template)
Option | Purpose | Kernow |
|---|---|---|
| Select a named template | yes |
Processing control:
Option -it is available only without an explicit source document. Any named template in the stylesheet can become the processing entry point.
<xsl:template name="hallo">
<html>
<body>
<h1>Hallo Welt!</h1>
<xsl:apply-templates select="fn:doc('beispiel.xml')/*"/>
</body>
</html>
</xsl:template>
To start with template hallo in named-template.xsl, invoke:
java net.sf.saxon.Transform -it:hallo named-template.xsl
Give the template name immediately after the option, then the stylesheet filename. That template always runs first and can call others or load any source documents, as demonstrated above with fn:doc().
-l:(on|off) (formerly: -l)
Option | Purpose | Kernow |
|---|---|---|
| Access source line numbers | no |
| No line-number access | no |
| Deprecated argument-free version | yes |
Debugging:
Option -l gives Saxon access to source line numbers, available inside the stylesheet through extension function saxon:line-number().
Note: Option -l without an argument remains in Saxon 9 for compatibility and equals explicit option -l:on. The argument-free version may disappear.
-m:classname (formerly: -m classname)
Option | Purpose | Kernow |
|---|---|---|
| Redirect messages to a log file | no |
Debugging:
Normally Saxon sends XML-fragment messages issued with xsl:message to standard error. Option -m specifies a Java class that receives this stream instead and redirects it to a log file.
-noext (deprecated)
Option | Purpose | Kernow |
|---|---|---|
| Disable extension function calls | no |
Security:
With option -noext, extension functions cannot be called except Saxon’s own or EXSLT extensions.
Note: Saxon 9 retains this only for compatibility; it may disappear. Instead use -ext:off.
-novw (deprecated)
Option | Purpose | Kernow |
|---|---|---|
| Suppress version warning | yes |
Suppressing the version warning:
Suppresses the normal W3C-specified warning when an XSLT 2.0 processor handles an XSLT 1.0 stylesheet.
Note: Saxon 9 retains this only for compatibility; it may disappear. Instead use -versionmsg:off.
-o:filename (formerly: -o filename)
Option | Purpose | Kernow |
|---|---|---|
| Create output file | Directly selectable |
Processing control:
Perhaps the most important option is -o. It sends results to the named file. Without it, transformation results go to standard output.
-or:classname (formerly: -or classname)
Option | Purpose | Kernow |
|---|---|---|
| URI resolver for | no |
Processing control:
The supplied Java class resolves URI strings passed as href- attribute values of xsl:result-document. It must implement interface net.sf.saxon.OutputURIResolver.
-outval:(recover|fatal)
Option | Purpose | Kernow |
|---|---|---|
| Allow result-document validation errors | no |
| Abort on validation error | no |
Controlling validation:
A result-document validation error normally aborts transformation with a message and no serialization. Option -outval:recover makes it only a warning on standard error and, if possible, a comment in the serialized result. With -outval:fatal, normal behavior is explicitly requested.
-p[:(on|off)]
Option | Purpose | Kernow |
|---|---|---|
| Enable PTreeURIResolver | no |
| Enable PTreeURIResolver | no |
| Disable PTreeURIResolver | no |
Processing control (Saxon-SA only):
Argument-free option -p and option -p:on enable schema-aware mode and interpretation of Saxon-specific file extensions in all URIs, including the command-line source. Option -p:off explicitly disables this.
Currently only extension .ptree (parsed tree) is used, allowing a previously processed XML file stored as “Saxon PTree” to load directly for faster processing.
Second, query parameters affecting schema validation are interpreted. Currently parameter val accepts values strict, lax or strip . For example, strict validation is requested with quelldokument.xml?val=strict.
Note: Option -p cannot accompany -r. It automatically enables -u and -sa, the URL-interpretation and schema-aware options.
-r:classname (formerly: -r classname)
Option | Purpose | Kernow |
|---|---|---|
| Include a URI resolver | no |
Processing control:
Option -r processes URIs through a custom Java class specified as URIResolver. This class must extend class net.sf.saxon.URIResolver (extends), accepting a URI string and returning a SaxInputSource handler. This can help include documents or stylesheet modules with xsl:include, xsl:import or function document(). It can resolve specially formed URIs, for example referencing a local repository:
<xsl:include href="mein_repository://modul2.xsl"/>
Option -u is also relevant here.
-repeat:integer
Option | Purpose | Kernow |
|---|---|---|
| Repeat transformation | no |
Performance measurement:
Option -repeat repeats the transformation the specified number of times. This eases performance measurement, otherwise distorted by Java startup latency on a single execution.
-s:filename (formerly: -s filename)
Option | Purpose | Kernow |
|---|---|---|
| Supply source document | no |
Processing control:
Required parameter -s supplies a source document or directory. The document node of its tree provides the initial context (initial context). A hyphen “-” instead of a filename makes Saxon read standard input (stdin).
With a directory, Saxon processes each document in turn. Option -o must name an output directory for result documents.
Note: Option -it cannot be set simultaneously. Source option -s may be omitted entirely with option -t.
-sa (deprecated)
Option | Purpose | Kernow |
|---|---|---|
| Enable schema-aware processing | no |
Processing control (Saxon-SA only):
Option -sa enables schema-aware processing. Without it the processor stays in basic mode.
Note: Omitting it causes schema-processing errors even with a valid Saxon-SA license: the processor behaves like the non-schema-aware basic version.
-sall (deprecated)
Option | Purpose | Kernow |
|---|---|---|
| Remove whitespace | no |
Processing control:
Removes all whitespace nodes before processing, independently of stylesheet xsl:strip-space instructions or source xml:space attributes.
Note: Saxon 9 retains this only for compatibility; it may disappear. Instead use -strip:all.
-signorable (deprecated)
Option | Purpose | Kernow |
|---|---|---|
| Remove ignorable whitespace | no |
Processing control:
Removes ignorable (ignorable) whitespace nodes before processing.
Note: Saxon 9 retains this only for compatibility; it may disappear. Instead use -strip:ignorable.
-snone (deprecated)
Option | Purpose | Kernow |
|---|---|---|
| Preserve whitespace | no |
Processing control:
Explicitly prevents whitespace removal before processing. Subsequent removal requested by xsl:strip-space is not disabled.
Note: Saxon 9 retains this only for compatibility; it may disappear. Instead use -strip:none.
-strip:(all|none|ignorable)
Option | Purpose | Kernow |
|---|---|---|
| Remove whitespace | no |
| Preserve whitespace | no |
| Remove ignorable whitespace | no |
Processing control:
Replaces deprecated options -snone, -sall and -signorable.
With -strip:all, all whitespace nodes are removed before processing, significant or not.
Option -strip:none explicitly forbids whitespace removal, but does not disable subsequent removal requested by xsl:strip-space.
With -strip:ignorable, only ignorable (ignorable) whitespace nodes are removed, independently of stylesheet xsl:strip-space instructions or source xml:space attributes. Whitespace is ignorable inside elements whose DTD/schema content model is element-only; source line breaks and indentation create such nodes.
-t
Option | Purpose | Kernow |
|---|---|---|
| Write to standard error | yes |
Processing information:
Option -t makes Saxon write additional information to standard error (stderr): processor version, transformation duration, resulting tree size and loaded extensions, plus full paths and filenames of source, stylesheet and result.
Figure: Saxon output with option -t
-T
Option | Purpose | Kernow |
|---|---|---|
| Trace to standard error | no |
Tracing and debugging:
The useful debugging option -T sends transformation tracing to standard error, recording instruction calls and their output with source-document line numbers.
Tracing is XML and can be processed or analyzed with XSLT, valuable given its potentially large volume.
-T:classname
Option | Purpose | Kernow |
|---|---|---|
| Trace to standard error | no |
Tracing and debugging:
If option -T receives a class name, it identifies a custom Java class receiving trace information. It must implement net.sf.saxon.trace.TraceListener.
Instruction calls and outputs are recorded with source-document line numbers.
-TJ
Option | Purpose | Kernow |
|---|---|---|
| Trace Java method calls | yes |
Debugging:
Option -TJ traces external Java method calls from stylesheets, as used by extensions. It helps when Saxon cannot find a method or when it is unclear which of several candidates is actually called.
-TL classname (deprecated)
Option | Purpose | Kernow |
|---|---|---|
| Java class as TraceListener | no |
Debugging:
Option -TL specifies a custom Java TraceListener class, which must implement net.sf.saxon.trace.TraceListener.
Note: Saxon 9 retains this only for compatibility; it may disappear. Instead use -T:classname.
Figure: A tracing document on standard output
-TP (deprecated)
Option | Purpose | Kernow |
|---|---|---|
| TraceListener with log file | no |
Debugging and optimization:
Option -TP activates, with TimedTraceListener, a special TraceListener logging timing information for instructions invoked during transformation. Performance analysis of these timings can guide stylesheet optimization.
Note: Saxon 9 retains this only for compatibility; it may disappear. Instead use -T:net.sf.saxon.trace.TimedTraceListener.
-tree:[linked|tiny]
Option | Purpose | Kernow |
|---|---|---|
| Standard tree mode | no |
| TinyTree mode (default) | no |
Processing control:
Replaces deprecated options -ds and -dt.
Option -tree:linked selects the traditional tree model (linked tree). Caution: this model cannot use node type annotations!
Alternative option -tree:tiny explicitly selects TinyTree, Saxon’s default. Unlike the traditional tree’s Java classes for nodes, TinyTree uses integer arrays, requiring less memory. Traditional trees can exceed source size by a factor of 50 per represented node and exhaust available memory.
TinyTree supports type annotations and suits long sources because it builds faster. However, XPath navigation along some axes, such as preceding or preceding-sibling, is slower. Duration therefore depends on stylesheet programming as well as source size. Both models produce identical results.
-u
Option | Purpose | Kernow |
|---|---|---|
| File paths as URLs | no |
Processing control:
Option -u treats source and stylesheet names as URLs. Otherwise they are filenames or directories unless explicitly starting with http: or file:.
-v (deprecated)
Option | Purpose | Kernow |
|---|---|---|
| Validate all source documents | no |
Validation:
Option -v requires a validating XML parser and validates the source plus documents loaded through function document(). It is unrelated to XML Schema support in the XSLT processor itself: Saxon-B and Saxon-SA behave alike.
Note: Saxon 9 retains this only for compatibility; it may disappear. Instead use -dtd:on.
-val[:(strict|lax)]
Option | Purpose | Kernow |
|---|---|---|
| Strict validation (deprecated) | no |
| Lax validation | no |
| Strict validation | no |
Validation:
Option -val:strict strictly validates the source and secondary sources loaded through function document(). Saxon-SA only; it automatically enables option -sa for schema-aware processing. Similarly, -val:lax validates when a schema is available, otherwise skips validation: lax validation.
Note: Argument-free option -val remains only for Saxon 9 compatibility and may disappear. Instead use -val:strict.
-versmsg:[on|off]
Option | Purpose | Kernow |
|---|---|---|
| Allow version warning | no |
| Suppress version warning | no |
Suppressing the version warning:
Replaces deprecated option -novw. Parameter -versmsg:off suppresses the W3C-required warning for processing XSLT 1.0 with an XSLT 2.0 processor. Variant -versmsg:on explicitly allows it.
-vlax (deprecated)
Option | Purpose | Kernow |
|---|---|---|
| Lax validation | no |
Validation:
Option -vlax validates if a schema is available; otherwise it does not. This is lax validation. It automatically enables option -sa for schema-aware processing. Saxon-SA only.
Note: Saxon 9 retains this only for compatibility; it may disappear. Instead use -val:lax.
-vw (deprecated)
Option | Purpose | Kernow |
|---|---|---|
| Warning instead of error | no |
Error handling:
Option -vw downgrades result-tree validation errors to warnings, allowing processing to continue when the result is invalid. Saxon-SA only.
Note: Saxon 9 retains this only for compatibility; it may disappear. Instead use -outval:recover.
-w0, -w1, -w2 (deprecated)
Option | Purpose | Kernow |
|---|---|---|
| Ignore errors silently | yes, alternatively |
| Continue after error message (default) | yes, alternatively |
| Always abort after error message | yes, alternatively |
Error handling and debugging:
These three options control stylesheet errors classified as recoverable errors, which need not abort transformation.
Option -w0 silently ignores such errors (recover silently), whereas -w1 reports them on standard error. Option -w2 reports and always aborts, even for recoverable errors.
Note: Saxon 9 retains this only for compatibility; it may disappear. Instead use -warnings:silent, -warnings:recover and -warnings:fatal.
-warnings:[silent|recover|fatal]
Option | Purpose | Kernow |
|---|---|---|
| Ignore errors silently | no |
| Continue after error message | no |
| Always abort after error message | no |
Error handling and debugging:
Replaces deprecated options -w0, -w1 and -w2.
Option -warnings uses three alternative arguments to control stylesheet errors classified as recoverable errors, which need not abort transformation.
Here -warnings:silent silently ignores these errors (recover silently), whereas -warnings:recover, Saxon’s default, reports to standard error. Option -warnings:fatal reports and always aborts, even for recoverable errors.
-x:classname (formerly: -x classname)
Option | Purpose | Kernow |
|---|---|---|
| SAX parser for | no |
Processing control:
Option -x specifies a Java SAX parser class for the source and documents loaded through function document(). Give a fully qualified class name (fully-qualified class name) implementing interface org.xml.sax.Parser or org.xml.sax.XMLReader.
-xi
Option | Purpose | Kernow |
|---|---|---|
| Apply XInclude | no |
Processing control:
Combines all participating documents, including sources, schemas and stylesheet modules, through XInclude into one Infoset.
Note: Currently this requires parser Xerces, included in JDK 1.5 onward. Option -xi is unavailable for .NET processing.
-xmlversion:[1.0|1.1]
Option | Purpose | Kernow |
|---|---|---|
| Allow XML 1.0 | no |
| Allow XML 1.1 | no |
Processing control:
Replaces deprecated option -1.1.
Option -xmlversion:1.1 correctly reads XML 1.1 sources and produces matching results, supporting Namespaces under the XML Namespaces 1.1 specification. It also permits XML 1.1 constructs in the stylesheet. Similarly, -xmlversion:1.0 specifies the default behavior.
-xsl:filename
Option | Purpose | Kernow |
|---|---|---|
| Include the principal stylesheet module | no |
Processing control:
Option -xsl includes the principal module. It is required unless options -a or -c are set. A hyphen “-” reads the stylesheet from standard input. With option -u, supply a URI instead of a filename.
Note: For compatibility, the stylesheet filename can still follow all options and precede parameters, without option -xsl.
-y:classname (formerly: -y classname)
Option | Purpose | Kernow |
|---|---|---|
| SAX parser for includes | no |
Processing control:
Option -y specifies a Java SAX parser class for the stylesheet and all modules included through xsl:include or xsl:import . Supply a fully qualified class name (fully-qualified class name) implementing interface org.xml.sax.Parser or org.xml.sax.XMLReader.
-1.1 (deprecated)
Option | Purpose | Kernow |
|---|---|---|
| Allow XML 1.1 | no |
Processing control:
Setting option -1.1 enables reading XML 1.1 sources and producing corresponding result documents.
Note: Saxon 9 retains this only for compatibility; it may disappear. Instead use -xmlversion:1.1.
-?
Option | Purpose | Kernow |
|---|---|---|
| Syntax help | no |
Help:
Option -? lists Saxon’s command-line syntax and brief option descriptions. No transformation starts, so no source or stylesheet need be supplied.
Copyright © Galileo Press, Bonn 2008
You may print the online version for your private use.
Otherwise, this chapter from “XSLT 2.0 & XPath 2.0 ― Das umfassende Handbuch” is subject to the same conditions as the bound edition. The work, including all its parts, is protected by copyright. All rights reserved, including reproduction, translation, microfilming, and storage and processing in electronic systems.
Galileo Press, Rheinwerkallee 4, 53227 Bonn