SAXONICA |
A command is available to run a query contained in a file. The form of command on the Java platform is:
java net.sf.saxon.Query [options] -q:queryfile [ params...]
On the .NET platform, the command is simply:
Query [options] -q:queryfile [ params...]
The options must come first, then the params. If the last option before the params has no leading hyphen ad option letter then it is recognized as the -q option.
The options are as follows (in any order). Square brackets indicate an optional parameter.
-backup:(on|off) |
Only relevant when -update:on is specified. Default is on. When backup is enabled, any file that is updated by the query will be preserved in its original state by renaming it, adding ".bak" to the original filename. If backup is disabled, updated files will be silently overwritten. |
-cr:classname |
Use the specified CollectionURIResolver to process collection URIs passed to the
|
-dtd:(on|off) |
Setting |
-expand:(on|off) |
Normally, if validation using a DTD or Schema is requested, any fixed or default values defined in the DTD or schema will be expanded. Specifying -expand:off suppresses this. (This might not work with all XML parsers) |
-explain[:filename] |
Display a query execution plan. This is a representation of the expression tree after rewriting by the optimizer. If no file name is specified the output is sent to the standard error stream. The output is a tree in XML format. |
-ext:(on|off) |
If |
-l[:(on|off)] |
If |
-mr:classname |
Use the specified ModuleURIResolver to process all query module URIs.
The ModuleURIResolver is a user-defined class
that implements the |
-o:filename |
Send output to named file. In the absence of this option, the results go to standard output. The output format depends on whether the -wrap option is present. |
-outval:(recover|fatal) |
Normally, if validation of result documents is requested, a validation error is fatal. Setting
the option |
-p[:(on|off)] |
Use the PTreeURIResolver. This option is available in Saxon-SA only. It cannot be used in conjunction
with the -r option, and it automatically switches on the -u and -sa options. The effect is twofold. Firstly, Saxon-specific
file extensions are recognized in URIs (including the URI of the source document on the command line). Currently
the only Saxon-specific file extension is |
-pipe:push|pull |
Execute query internally in push or pull mode. Default is push. This may give performance advantages for certain kinds of query, especially queries that construct intermediate trees in memory. In practice when the output is serialized there is usually little difference, and the option is there mainly for testing. |
-projection:(on|off) |
Use (or don't use) document projection. Document Projection is a mechanism that analyzes a query to determine what parts of a document it can potentially access, and then while building a tree to represent the document, leaves out those parts of the tree that cannot make any difference to the result of the query. Requires Saxon-SA. |
-q:queryfile |
Identifies the file containing the query. The file can be specified as "-" to read the query from standard input. If this is the last option then the "-q:" prefix may be omitted. |
-qs:querystring |
Allows the query to be specified
inline (if it contains spaces, you will need quotes
around the expression to keep the command line processor happy).
For example |
-r:classname |
Use the specified URIResolver to process all URIs. The URIResolver is a user-defined class, that implements the URIResolver interface defined in JAXP, whose function is to take a URI supplied as a string, and return a SAX InputSource. It is invoked to process URIs used in the doc() function, and (if -u is also specified) to process the URI of the source file provided on the command line. |
-repeat:integer |
Performs the transformation N times, where N is the specified integer. This option is useful for performance measurement, since timings for the first few runs of the query are often dominated by Java warm-up time. |
-s:filename-or-URI |
Take input from the specified file. If the -u option is specified, or if the name begins with "file:" or "http:", then the name is assumed to be a URI rather than a filename. This file must contain an XML document. The document node of the document is made available to the query as the context item. The source document can be specified as "-" to take the source from standard input. |
-sa |
Invoke a schema-aware transformation. Requires Saxon-SA to be installed. |
-strip:(all|none|ignorable) |
Specifies what whitespace is to be stripped from source documents (applies both to the principal source
document and to any documents loaded for example using the |
-t |
Display version and timing information to the standard error output. The output also traces the files that are read and written, and extension modules that are loaded. |
-T[:classname] |
Notify query tracing information. Also switches line numbering on for the source document. If a classname is specified, it is a user-defined class, which must implement net.sf.saxon.trace.TraceListener. If the classname is omitted, a system-supplied trace listener is used. This traces execution of function calls to the standard error output. |
-TJ |
Switches on tracing of the binding of calls to external Java methods. This is useful when analyzing why Saxon fails to find a Java method to match an extension function call in the stylesheet, or why it chooses one method over another when several are available. |
-traceout:filename |
Indicates that the output of the |
-tree:[linked|tiny] |
Selects the implementation of the internal tree model. -tree:tiny the "tiny tree" model (the default). -tree:linked selects the linked tree model. See Choosing a tree model. |
-u |
Indicates that the name of the source document is a URI; otherwise it is taken as a filename, unless it starts with "http:" or "file:", in which case they it is taken as a URL. |
-update:[on|off|discard] |
Indicates whether XQuery Update syntax is accepted. This option requires Saxon-SA. The value "on" enables XQuery update; any files updated by the query are written back to filestore if they have a known document URI and that URI is an updateable location. The default value "off" disables update (any use of XQuery update syntax is an error). The value "discard" allows XQuery Update syntax, but modifications made to files are not saved in filestore. If the document supplied in the -s option is updated, the updated document is serialized as the result of the query (writing it to the -o destination); updates to any other documents are simply discarded. |
-val[:(strict|lax)] |
Requests schema-based validation of the source file and of any files read using the doc()
function. This option is available only with Saxon-SA, and it automatically switches on the
-sa option. Specify |
-wrap |
Wraps the result sequence in an XML element structure that indicates the type of each node or
atomic value in the query result. This format can handle any type of query result. In the
absence of this option, the command effectively wraps a |
-x:classname |
Use specified SAX parser for source file and any files loaded using the document() function. The parser must be the fully-qualified class name of a Java class that implements the org.xml.sax.Parser or org.xml.sax.XMLReader interface |
-xi |
Apply XInclude processing to all input XML documents (including schema documents as well as source documents). This currently only works when documents are parsed using the Xerces parser, which is the default in JDK 1.5 and later. |
-xmlversion:[1.0|1.1] |
If |
-xsd:file1;file2;file3... |
Loads additional schema documents. The declarations in these schema documents are available when
validating source documents (or for use by the |
-xsdversion:[1.0|1.1] |
If |
-xsiloc:on|off |
If set to "on" (the default) the schema processor attempts to load any schema documents referenced
in |
-? |
Display command syntax |
The following options are also available for backwards compatibility, but are likely
to be withdrawn at some time in the future. Also, where previous releases allowed an option and
a value to be separated by a space rather than a colon (for example -r uriresolver
),
this syntax should still work for the time being.
-ds | -dt |
|
-e |
Equivalent to -explain. |
-noext |
Equivalent to |
-novw |
Equivalent to |
-sall |
Equivalent to |
-signorable |
Equivalent to |
-snone |
Equivalent to |
-TL classname |
Equivalent to |
-TP |
Equivalent to |
-v |
Equivalent to |
-val |
Equivalent to |
-vlax |
Equivalent to |
-vw |
Equivalent to |
-1.1 |
Equivalent to |
A param takes the form name=value
, name being the
name of the parameter, and value the value of the parameter. These parameters are
accessible within the query as external variables, using the $name
syntax, provided
they are declared in the query prolog. If there is no such declaration, the supplied
parameter value is silently ignored.
A param preceded by a leading plus sign (+) is interpreted as a filename or directory.
The content of the file is parsed as XML, and the resulting document node is passed to the stylesheet
as the value of the parameter. If the parameter value is a directory, then all the immediately contained
files are parsed as XML, and the resulting sequence of document nodes is passed as the value of the
parameter. For example, +lookup=lookup.xml
sets the value of the external variable
lookup
to the document node at the root of the tree representing the parsed contents
of the file lookup.xml
.
A param preceded by a leading exclamation mark is interpreted as a serialization parameter.
For example, !indent=yes
requests indented output, and !encoding=iso-8859-1
requests that the serialized output be in ISO 8859/1 encoding. This is equivalent to specifying
the option declaration declare option saxon:output "indent=yes";
or
declare option saxon:output "encoding=iso-8859-1";
in the query prolog.
Under Windows, and some other operating systems, it is possible to supply a value containing
spaces by enclosing it in double quotes, for example name="John Smith"
. This is a feature
of the operating system shell, not something Saxon does, so it may not work the
same way under every operating system.
If the parameter name is in a non-null namespace, the parameter can be given a value using
the syntax {uri}localname=value
. Here uri
is the namespace URI of the
parameter's name, and localname
is the local part of the name.
This applies also to output parameters. For example, you can set the indentation level to 4 by
using the parameter !{http://saxon.sf.net/}indent-spaces=4
. For the extended set of
output parameters supported by Saxon, see
Additional serialization parameters.