XML and XQuery files can be passed on as parameters. If an XML file is passed, a database instance is created from this file, or an existing database is opened. If an XQuery expression is passed on, it is opened in the XQuery editor.
==BaseX Standalone==
;Launch the interactive mode:
<pre>
> basex
BaseX [Standalone]
Try "help" to get more information.
>_</pre>
Available command-line options can be listed with the <code>-h</code> flag:
<pre>
> basex -h
Usage: BaseX [-diosuvVwz] [-cq] [file]
[file] Execute XQuery file
-b<pars> Bind external XQuery variables
-c<cmd> Execute database command(s)
-d Activate debugging mode
-i<input> Open initial file or database
-o<file> Write output to file
-q<expr> Execute XQuery expression
-s<pars> Set serialization parameter(s)
-u Modifiy original files after updates
-v/V Show (all) process info
-w Retain whitespaces from source files
-z Skip output of results
</pre>
The options have the following meaning:
{| class="wikitable"
|- valign="top"
! width='75' | Flag
! Description
! width='165' | Examples
|- valign="top"
| <code>[file]</code>
| Execute the specified XQuery file.
|
|- valign="top"
|- valign="top"
| <code>-b<pars></code>
| Bind external variables to XQuery expressions. This flag may be specified multiple times; key/value pairs are separated by equality signs (<code>=</code>).
| <code>-bv=example<br />-q"declare variable $v external; $v"</code>
|- valign="top"
| <code>-c<cmd></code>
| Launch database commands and skip interactive mode. The flag should be placed last, as all remaining characters are interpreted as commands. Several commands can be separated by semicolons.
| <code>-c"list;info"</code>
|- valign="top"
| <code>-d</code>
| Turn on debugging. Debugging information is output to ''standard error''.
|
|- valign="top"
| <code>-i<input></code>
| Open a database or XML document specified by the argument. The opened input may be further processed by an XQuery expression.
| <code>-iitems.xml -q"//item"</code>
|- valign="top"
| <code>-o<file></code>
| Command and query output is written to the specified file.
| <code></code>
|- valign="top"
| <code>-q<expr></code>
| Execute the specified string as XQuery expression. The flag should be placed last, as all remaining characters are interpreted as XQuery.
| <code>-q"doc('input')//head"</code>
|- valign="top"
| <code>-s<pars></code>
| Specify parameters for serializing XQuery results; see [[Serialization]] for more details. This flag may be specified multiple times; key/value pairs are separated by equality signs (<code>=</code>).
| <code>-smethod=text</code>
|- valign="top"
| <code>-u</code>
| Modify original files after evaluating XQuery Update expressions.
|
|- valign="top"
| <code>-v</code>
| Process information is written to ''standard output''.
|
|- valign="top"
| <code>-V</code>
| Detailed query information is written to ''standard output'', including compilation and profiling steps.
|
|- valign="top"
| <code>-w</code>
| By default, whitespaces around text nodes are [[Options#CHOP|chopped]] when a database is created. This flag can be specified to suppress chopping.
|
|- valign="top"
| <code>-z</code>
| Skip the serialization of XQuery results. This flag is useful for analyzing query plans.
|
|}
==BaseX Server==
| Skip the serialization of XQuery results. This flag is useful for analyzing query plans.
|
|
|}
==BaseX Standalone==
;Launch the interactive mode:
<pre>
> basex
BaseX [Standalone]
Try "help" to get more information.
>_</pre>
Available command-line options can be listed with the <code>-h</code> flag:
<pre>
> basex -h
Usage: BaseX [-diosuvVwz] [-cq] [file]
[file] Execute XQuery file
-b<pars> Bind external XQuery variables
-c<cmd> Execute database command(s)
-d Activate debugging mode
-i<input> Open initial file or database
-o<file> Write output to file
-q<expr> Execute XQuery expression
-s<pars> Set serialization parameter(s)
-u Modifiy original files after updates
-v/V Show (all) process info
-w Retain whitespaces from source files
-z Skip output of results
</pre>
The options have the following meaning:
{| class="wikitable"
|- valign="top"
! width='75' | Flag
! Description
! width='165' | Examples
|- valign="top"
| <code>[file]</code>
| Execute the specified XQuery file.
|
|- valign="top"
|- valign="top"
| <code>-b<pars></code>
| Bind external variables to XQuery expressions. This flag may be specified multiple times; key/value pairs are separated by equality signs (<code>=</code>).
| <code>-bv=example<br />-q"declare variable $v external; $v"</code>
|- valign="top"
| <code>-c<cmd></code>
| Launch database commands and skip interactive mode. The flag should be placed last, as all remaining characters are interpreted as commands. Several commands can be separated by semicolons.
| <code>-c"list;info"</code>
|- valign="top"
| <code>-d</code>
| Turn on debugging. Debugging information is output to ''standard error''.
|
|- valign="top"
| <code>-i<input></code>
| Open a database or XML document specified by the argument. The opened input may be further processed by an XQuery expression.
| <code>-iitems.xml -q"//item"</code>
|- valign="top"
| <code>-o<file></code>
| Command and query output is written to the specified file.
| <code></code>
|- valign="top"
| <code>-q<expr></code>
| Execute the specified string as XQuery expression. The flag should be placed last, as all remaining characters are interpreted as XQuery.
| <code>-q"doc('input')//head"</code>
|- valign="top"
| <code>-s<pars></code>
| Specify parameters for serializing XQuery results; see [[Serialization]] for more details. This flag may be specified multiple times; key/value pairs are separated by equality signs (<code>=</code>).
| <code>-smethod=text</code>
|- valign="top"
| <code>-u</code>
| Modify original files after evaluating XQuery Update expressions.
|
|- valign="top"
| <code>-v</code>
| Process information is written to ''standard output''.
|
|- valign="top"
| <code>-V</code>
| Detailed query information is written to ''standard output'', including compilation and profiling steps.
|
|- valign="top"
| <code>-w</code>
| By default, whitespaces around text nodes are [[Options#CHOP|chopped]] when a database is created. This flag can be specified to suppress chopping.
|
|- valign="top"
| <code>-z</code>
| Skip the serialization of XQuery results. This flag is useful for analyzing query plans.
|
|}