Previous Up Next

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.

Usage: galax-run options query.xq

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 on
   -dynamic on 
By default, all result values (XML result, 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. Here are the available options. Default values are in code font.
-help,--help
Display this list of options

5.1.1  Input options

-base-uri
Sets the default base URI in the static context
-var
var=filename, Binds the global variable var to document in filename
-context-item
Binds the context item (``.'' variable) to the document in filename or '-' for stdin
-context
Load the context query from file or '-' for stdin
-xml-whitespace
Preserves whitespace in XML documents [on/off]
-xml-pic
Preserves PI's and comments in XML documents [on/off]
xquery-whitespace
Preserves whitespace in XQuery expressions [on/off]

5.1.2  Output options

-serialize
Set serialization kind [wf, canonical, or xquery]
-serialize-namespaces
Set serialization of namespace nodes [strip/preserve]

5.1.3  Evaluation options

-dynamic
Evaluation phase [on/off]

-print-xml
Print XML result [on/off]
-output-xml
Output XML to result file

-print-expr
Print input expression [on/off]
-output-expr
Output expr to file.

5.1.4  Normalization options

-normalize
Normalization phase [on/off]
-print-normalized-expr
Print normalized expression [on/off]
-output-normalized-expr
Output normalized expression to file.

5.1.5  Static typing options

-static
Static analysis phase [on/off]
-typing
Static typing behavior [none, weak, or strong]

-print-type
Print type of expression [on/off]
-output-type
Output type to file.

-print-typed-expr
Print typed expression [on/off]
-output-typed-expr
Output typed expression to file.

5.1.6  Optimization options

-optim
Optimization phase (use with -static on) [on/off]
-sbdo
Document-order/duplicate-elimination optimization behavior [remove, preserve, adhoc, or automata]

-print-optimized-expr
Print optimized expression [on/off]
-output-optimized-expr
Output optimized expression to file.

5.1.7  Miscellaneous printing options

-verbose
Emit descriptive headers in output [on/off]
-output-all
Output everything to file.
-print-error-code
Print only the error code instead of the full error message

-print-context-item
Serializes the context item at the end of query evaluation
-output-context-item
Output the context item to the given file

-print-annotations
Print expression annotations [on/off]

-print-logical-plan
Print out the logical plan [on/off]
-output-logical-plan
Output the logical plan to a file

-print-physical-plan
Print the physical plan [on/off]
-output-physical-plan
Output the physical algebraic plan to a file

5.1.8  Document projection options

-projection
Document projection behavior [none, standard, or optimized]
-print-projection
Prints the projection paths
-output-projection
Output the projections paths to a file.

-print-projected-file
Prints back the input document after projection
-output-projected-file
Output the input document after projection into file.

-pretty-print-module
Pretty printing the whole module
-pretty-print
Pretty printing the query to file 'filename_pretty.xq'

5.1.9  Miscellaneous options

-version
Prints the Galax version
-debug
Emit debugging [on/off]

-monitor
Monitors memory and CPU consumption [on/off]
-monitor-mem
Monitors memory consumption [on/off]
-monitor-time
Monitors CPU consumption [on/off]
-output-monitor
Output monitor actibity to file

-internal-encoding
Set the input character encoding representation, e.g., utf8, iso88591.
-output-encoding
Set the output character encoding representation

5.2  galax-parse: XML parser and XML Schema validator

galax-parse parses an XML document and optionally validates the document against an XML Schema.

Usage: galax-parse options document.xml
-help,--help
Display this list of options

-xml-whitespace
Preserves whitespace in XML documents
-xml-pic
Preserves PI's and comments in XML documents

-validate
Set validation on
-xmlschema
Schema against which to perform validation

-dm
Also builds the data model instance

-monitor
Monitors memory and CPU consumption
-monitor-mem
Monitors memory consumption
-monitor-time
Monitors CPU consumption
-output-monitor
Output monitor to file

-serialize-namespaces
Set serialization of namespace nodes [strip/preserve]

-serialize
Set serialization kind [canonical, wf, or xquery]

-print-error-code
Print only the error code instead of the full error message
-output-encoding
Set the output encoding representation

5.3  galax-mapschema : XML Schema validator

galax-mapschema maps XML schemas in xmlschema(s) into XQuery type expressions.

Usage: galax-mapschema options schema.xsd
-prefix
Namespace prefix
-verbose
Set printing to verbose
-import-type
Set XML Schema import
-normalize-type
Set XQuery type normalization

-print-type
Set printing ofXQuery type
-print-normalized-type
Set printing of normalized XQuery type

-output-type
Output XQuery type in file
-output-normalized-type
Output normalized XQuery type in file

Previous Up Next