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

-a

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.

Back to top

 

-c:filename

Option

Purpose

Kernow

-c:filename

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

-cr:classname

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.

Back to top

-dtd:(on|off)

Option

Purpose

Kernow

-dtd:on

Enable DTD validation

no

-dtd:off

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

-ds

Standard tree mode

yes, alternatively

-dt

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.

Back to top

-expand:(on|off)

Option

Purpose

Kernow

-expand:on

Expand default values

no

-expand:off

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

-explain[:filename]

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

-ext:on

Allow extension functions

no

-ext:off

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.

Back to top

-im:modename (formerly: -im modename)

Option

Purpose

Kernow

-im:modename

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

-it:template

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().

Back to top

-l:(on|off) (formerly: -l)

Option

Purpose

Kernow

-l:on

Access source line numbers

no

-l:on

No line-number access

no

-l

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.

Back to top

-m:classname (formerly: -m classname)

Option

Purpose

Kernow

-m:classname

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.

Back to top

-noext (deprecated)

Option

Purpose

Kernow

-noext

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

-novw

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.

Back to top

-o:filename (formerly: -o filename)

Option

Purpose

Kernow

-o:filename

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

-or:classname

URI resolver for xsl:result-document

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

-outval:recover

Allow result-document validation errors

no

-outval:fatal

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.

Back to top

-p[:(on|off)]

Option

Purpose

Kernow

-p

Enable PTreeURIResolver

no

-p:on

Enable PTreeURIResolver

no

-p:off

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.

Back to top

-r:classname (formerly: -r classname)

Option

Purpose

Kernow

-r:classname

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:integer

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.

Back to top

-s:filename (formerly: -s filename)

Option

Purpose

Kernow

-s:filename

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

-sa

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

-sall

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

-signorable

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

-snone

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

-strip:all

Remove whitespace

no

-strip:none

Preserve whitespace

no

-strip:ignorable

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.

Back to top

-t

Option

Purpose

Kernow

-t 

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.

Saxon output with option -t

Figure: Saxon output with option -t

-T

Option

Purpose

Kernow

-T 

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

-T:classname

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

-TJ 

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

-TL classname

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.

A tracing document on standard output

Figure: A tracing document on standard output

-TP (deprecated)

Option

Purpose

Kernow

-TP

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

-tree:linked

Standard tree mode

no

-tree:tiny

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.

Back to top

-u

Option

Purpose

Kernow

-u

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:.

Back to top

-v (deprecated)

Option

Purpose

Kernow

-v

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

-val

Strict validation (deprecated)

no

-val:strict

Lax validation

no

-val:lax

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

-versmsg:on

Allow version warning

no

-versmsg:off

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

-vlax

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

-vw

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.

Back to top

-w0, -w1, -w2 (deprecated)

Option

Purpose

Kernow

-w0

Ignore errors silently

yes, alternatively

-w1

Continue after error message (default)

yes, alternatively

-w2

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

-warnings:silent

Ignore errors silently

no

-warnings:recover

Continue after error message

no

-warnings:fatal

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.

Back to top

-x:classname (formerly: -x classname)

Option

Purpose

Kernow

-x:classname

SAX parser for document()

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

-xi

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

-xmlversion:1.0

Allow XML 1.0

no

-xmlversion:1.1

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

-xsl:filename

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.

Back to top

-y:classname (formerly: -y classname)

Option

Purpose

Kernow

-y:classname

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.

Back to top

-1.1 (deprecated)

Option

Purpose

Kernow

-1.1

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.

Back to top

-?

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.

Back to top

  

 

 

 

back to top