XQuery Command Line Reference

XQuery.exe is the XmlPrime command line XQuery processor. It executes a specified query, with the specified options.

The command-line options are case sensitive.

 
XQuery.exe [Options] [XQueryFile] [Parameters]
 

Arguments

ArgumentDescription

XQueryFile

The path to the query. The query can either be in textual XQuery format, or the XML XQueryX format (with the extension .xml or .xqx). Alternatively, replacing query.xq with a single "-" character indicates that the query should be read from the standard input stream.

Options

OptionAliasDescription

--compile

--c

Compiles and optimizes the query without running it. This can be useful to ensure a query is valid, without having a suitable input document at hand, and also for benchmarking purposes.

--dtd

--d

Enables the use of DTDs to validate input documents. By default, documents are not validated against their DTDs. Note that the DTDs are retrieved even when this option is disabled, as they are used to resolve entity references.

--emacs

Output errors and warnings in an single line format.

--explain

--e

Displays the query execution plan. This is a representation of the query after it has been compiled and fully optimized. This explains how XmlPrime intends to perform the query, and can be useful in highlighting errors in queries if they are producing unexpected results. The execution plan is output to the standard error stream.

--help

-?

Displays usage instructions for the command line tool.

--multiple

-m

Allows multiple compilation errors to be reported. By default, compilation is aborted after the first error is discovered.

--noserialize

Prevents the result of the query from being serialized and output. This is useful in combination with --time to measure the time taken to evaluate the query independent of the time taken to serialize the output.

-o filename

Specifies a file to which the output of the query should be written. If the file already exists it is overwritten, otherwise a new file is created. If this option is omitted then the output of the query is sent to the standard output.

-O0

Disables compiler optimizations. This cannot be used in conjunction with any other -O option.

-O1

Disables any compiler optimizations that significantly change the structure of the query. This is useful for producing an execution plan if the result of a query is not what you expect. This cannot be used in conjunction with any other -O option.

-O2

Disables join optimizations. This feature is mainly for testing purposes. This cannot be used in conjunction with any other -O option.

-O3

Enabled join optimizations. This is the default optimization level. This cannot be used in conjunction with any other -O option.

--pedantic

Enables static type checking according exactly to the type checking rules as specified in the W3C XQuery Formal Semantics specification. In pedantic mode, XmlPrime-specific extended type checking rules are not used. This cannot be used in conjunction with the --static option.

--preserve

Preserves all white space text nodes in all input documents. This cannot be used in conjunction with the

--strip
option.

--repeat n

Repeats compilation and evaluation of the query n times. This can be used in order to get more accurate timing measurements, since initialization can take a long time and dominate the first few runs. Note that this will also cause the result of the query to be serialized and output n times.

-s document

Sets the context document for the query. document can either be a path to, or the URI of, an XML document to use as the context item.

--schema

-v

Validates input documents with XML Schema against the available schemas. All documents passed in on the command line or read by the transformation are validated against the available schemas. The available schemas used for validation contain:

  • Schemas imported using the --xsd option.
  • Schemas imported in the query.
  • Unless the --noxsiloc option is set, any schemas referenced in xs:schemaLocation or xs:noNamespaceSchemaLocation attributes are used to validate the document.

Note that this does not affect validate expressions, which will only validate against schemas imported in the query.

--strip

Strips insignificant whitespace text nodes from all input documents. This cannot be used in conjunction with the --preserve option.

--time

-t

Displays the time taken to analyse and evaluate the query. Timing information is sent to the standard error stream. To get more accurate timings, this can be used in combination with the --repeats and --noserialize flags.

--trace

This option causes a message to be output to the console every time a document is accessed by the query, and enables output from the trace function in the query to be displayed. Trace information is sent to the standard error stream.

--unix

-u

Indicates that the output should use UNIX line endings (LF, a single "
" line feed character). By default, any new-line characters in the output document are replaced with a CRLF ("
").

--version

This option causes version information to be output to the console.

---xsd schema

-x schema

Specifies the filename of an XML Schema to be added to the set of schemas available for validation. This mechanism also specifies the location of schemas imported in the query with no location hints. If the query imports a schema with the same namespace, then the schema supplied on the command line is used, regardless of which location hints are used.

--noxsiloc

Prevents schemas referenced by xsi:schemaLocation or xsi:noNamespaceSchemaLocation in imported documents from being loaded and added to the set of schemas used for validation.

Parameters

ParameterDescription

parametername=expression

Sets a query parameter to the specified value.

A query parameter is the definition of a global variable declared as external in the query or an imported module.

The parametername is the local name of the parameter to be set. The parameter is assumed to have no namespace. An external variable declared with a namespace can be referred to with the syntax {namespace}localname. If no external variable is found with the specified name, then this parameter is ignored.

expression is an expression which is evaluated to give the value of the parameter.

+parametername=document

Sets a query parameter to the specified document.

A query parameter is the definition of a global variable declared as external in the query or an imported module.

The parametername is the local name of the parameter to be set. The parameter is assumed to have no namespace. An external variable declared with a namespace can be referred to with the syntax {namespace}localname. If no external variable is found with the specified name, then this parameter is ignored.

document isa path or URI to an XML document.

!parameter=value=value

Sets a serialization parameter.

Serialization parameters define how the result of the query is serialized. This is equivalent to adding the following declarations to the query:

 
              
              declare namespace serialization="http://www.xmlprime.com/serialization";
              declare option serialization:parameter "value";
            
 

If the requested serialization parameter does not exist this parameter is ignored. If a parameter is also set in the query, then the value passed on the command line takes precedence.