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

--benchmark n

-b n

Enables benchmarking mode

--collection uri

Specifies the default collection URI uri, which must be a valid URI.

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

-il

Specifies that the processor should compile the query to CIL byte code. This is only supported in the commercially licensed product.

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

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

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

-O4

Enables function specialization. This may significantly increase the compilation time. 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.

--plan filename

-p filename

Write the execution plan as XML to the named file

--preserve

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

--profile filename

Write the profiling information to the named file

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

--schema-aware

-sa

Enables schema-aware processing.

By default, schema-aware processing is not enabled, and input documents are assumed to by untyped.

--static

Enables static type checking using rules which improve on those in the W3C XQuery Formal Semantics specification. This cannot be used in conjunction with the --pedantic option.

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

--timezone z

Sets the implicit timezone. The timezone value z is specified in the form (('+' | '-') hh ':' mm) or the value 'Z', e.g. +01:00.

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

--version

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

--xml10

Use XML 1.0 (5th edition) and Namespaces in XML 1.0. Note that in the current version, only XML 1.0 4th edition documents can be used as inputs.

--xml11

Use XML 1.1 (2nd edition) and Namespaces in XML 1.1. Note that in the current version, only XML 1.0 4th editino documents can be used as inputs.

--xq10

Behave as an XQuery 1.0 processor.

--xq30

Behave as an XQuery 3.0 processor.

--xq31

Behave as an XQuery 3.1 processor.

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

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 XQuery expression that matches the ExprSingle production in the XQuery grammar. This is the same as the syntax that is valid for the definition of a global variable in an XQuery program.

Note that when passing string-valued parameters using Command Prompt or Powershell, extra quoting is required, for example "param='cheese'".

+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 is a 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.

For a detailed description of all the available serialization parameters, see Serialization parameters.