Chapter 5 Command Line Tools
Galax supports the following stand-alone command-line tools:
-
galax-run
- The Galax XQuery interpreter.
- galax-parse
- XML document parser and validator.
- galax-mapschema
- XML Schema validator. Outputs XML Schema in XQuery type system.
5.1 galax-run : The Galax XQuery interpreter
The simplest way to use Galax is by calling the 'galax-run' interpreter
from the command line. The interpreter takes an XQuery input file,
evaluates it, and yields the result on standard output.
For instance, the following commands from the Galax home directory:
% echo "<two> 1+1 </two>" > test.xq
% $(GALAXHOME)/bin/galax-run test.xq
<two>2</two>
evaluates the simple query <two> { 1+1 } </two>
and prints the
XML value <two>2</two>
.
The query interpreter has five processing stages:
parsing an XQuery expression;
normalizing an XQuery expression into an XQuery core expression;
static typing of a core expression;
optimizing a core expression;
and evaluating a core expression.
Parsing is always enabled. By default, the other phases are:
-normalize on
-static off
-optim off
-dynamic on
By default, all results (XML answer, inferred type, etc.) are written
to standard output.
The command line options permit various combinations of phases,
printing intermediate expressions, and redirecting output to multiple
output files.
Usage: galax-run [-version] [-context file] [-pic]
[-xml-whitespace] [-xquery-whitespace]
[-normalize on/off] [-static on/off] [-optim on/off] [-dynamic on/off]
[-print-xml on/off] [-output-xml filename]
[-print-type on/off] [-output-type filename]
[-print-expr on/off] [-output-expr filename]
[-print-normalized-expr on/off] [-output-normalized-expr filename]
[-print-typed-expr on/off] [-output-typed-expr filename]
[-print-optimized-expr on/off] [-output-optimized-expr filename]
[-pretty-print filename] [-print-type-annotations on/off]
[-output-all filename] [-serialize-wf] [-debug] [-verbose]
[-projection on/off] [-optimized-projection on/off]
[-print-projection on/off] [-output-projection filename]
[-print-projected-file on/off] [-output-projected-file filename]
[-monitor on/off] [-output-monitor filename]
[-blocking on/off]
[-base-uri URI]
query-filename(s)
Evaluate XQuery queries in query-filename(s)
Default values are in square brackets []:
-version Prints Galax version number
-context Loads the static context from file. This static
context is passed to all queries.
-xquery-whitespace Preserves whitespace in XQuery expressions [off]
-xml-whitespace Preserves whitespace in XML documents [off]
-pic Preserves PI's and comments in input documents [off]
-normalize Normalization phase [on]
-static Static analysis phase (requires -normalize on) [off]
-optim Optimization phase (most useful with -static on) [off]
-dynamic Evaluation phase (requires -normalize on) [on]
-print-xml Print XML result [on]
-output-xml Output XML to result file [standard output]
-print-type Print type of expression [off]
-output-type Output type to file. [standard output]
-print-expr Print input expression [off]
-output-expr Output expr to file. [standard output]
-print-normalized-expr Print normalized expression [off]
-output-normalized-expr Output normalized expression to file. [standard output]
-print-typed-expr Print typed expression [off]
-output-typed-expr Output typed expression to file. [standard output]
-print-optimized-expr Print optimized expression [off]
-output-optimized-expr Output optimized expression to file. [standard output]
-print-type-annotations Print type annotations of expressions [off]
-pretty-print Pretty printing the whole query, with
all of the results to file 'filename_pretty.xq'
-monitor on Monitor & print memory and CPU usage
-output-monitor filename
-blocking Stops at the first error
-base-uri Sets the default base URI in the static context
-output-all Output everything to file. [off]
-serialize-wf Serialize well-formed XML. By default, result
is serialized as XQuery data model value.
-projection Projection of documents
-optimized-projection Optimized projection of documents
-print-projection Prints the projection paths
-output-projection Output the projections paths to a file.
-debug Emit debugging information
-verbose Emit descriptive headers in output [off]
-help display this list of options
--help display this list of options
5.2 galax-parse: XML parser and XML Schema validator
Usage: validate [-schema file -root qname [-prefix prefix]]
[-typesyntax] [-print] [-whitespace] [-dm] [-wf] file(s)
Validates XML documents in file(s) using specified schema
-print Pretty print the input document
-whitespace Preserve white space
-dm Also build the data model instance
-wf Checks only for well-formedness
-prefix Schema namespace prefix
-typesyntax Uses XQuery type system syntax instead of XML Schema syntax
-schema XML Schema file
-root Schema root type
-help display this list of options
--help display this list of options
5.3 galax-mapschema : XML Schema validator
Usage: galax-mapschema [-prefix prefix] [-typesyntax] [-output file]
schemafile(s)
Maps schemas in schemafile(s) into XQuery type expressions.
-prefix Namespace prefix
-output Emit mapped schema in file
-typesyntax Uses XQuery type system syntax instead of XML Schema syntax
-help display this list of options
--help display this list of options