This article is part of the [[Getting Started]] Guide.
Each BaseX [[Startup]] mode has one or more command-line options , which are described in this article.
Command-line options can be specified multiple times. Please note that all options will be evaluated in the given order. The standard input can be parsed by specifying a single dash ({{Code|-}}) as an argument. {{Announce|Updated with Version 11}}: The Clark notation was replaced with the [[XQuery 3.0#Expanded QNames|Expanded QNames]] notation.
=Standalone=
;Launch the standalone (console) mode{{Announce|Added with Version 11:}} {{Code|-C}}, {{Code|-Q}}, {{Code|-W}}<pre>$ basexBaseX The following options are available for the standalone [[StandaloneCommand-Line Client]Try "help" to get more information.> _</pre>]:
You can list the command-line options available for the standalone mode using {{Code|-h}}:
<pre>
$ basex -h
-b<args> Bind external query variables
-c<input> Execute commands from file or string
-C<file> Execute command script file
-d Toggle debugging output
-i<input> Bind file or database to context
-o<path> Write output to local file
-q<expr> Execute XQuery expression
-Q<file> Execute XQuery file
-r<num> Run query multiple times
-R Toggle query execution
-v Toggle output of progress info
-V Toggle detailed query output
-w Toggle whitespace choppingstripping -W Enable indentation with whitespaces
-x Toggle output of query plan
-z Toggle output of query result
</pre>
The meaning of all options is Further details are listed in the following table. If an equivalent database option exists (which can be specified via the <code>[[Commands#SET{{Command|SET]]</code> }} command), it is listed as well. For the examples to work, it might be necessary to escape some characters, depending on your Operating Systemoperating system.
{| class="wikitable"
| {{Code|[input]}}
|Evaluates the specified input:
* The input string may point to an existing file. If the file suffix is {{Code|.bxs}}, the file contents will be evaluated executed as [[Commands#Basics|Command Script]]; any other file content will be evaluated as XQuery expression.
* Otherwise, the input string itself is evaluated as XQuery expression.
|
|- valign="top"
| {{Code|-b<args>}}
| Binds external variables to XQuery expressions. This flag may be specified multiple times. Variables names and their values are delimited by equality signs (<code>=</code>). The names may be optionally prefixed with dollar signs. If a variable uses a namespace different to from the default namespace, it can be specified with the [http://www[XQuery 3.jclark.com/xml/xmlns.htm Clark Notation0#Expanded QNames|Expanded QNames]]notation.| <code>[[Options#BINDINGS{{Option|BINDINGS]]</code>}}
|
|• <code>-bv=example "declare variable $v external; $v"</code><br/>• <code>-bbQ{URL}ln=value<br/>"declare namespace ns='URL'; declare variable $ns:ln external; $ns:ln"</code>
|- valign="top"
| {{Code|-c<input>}}
| Executes [[commands]]:* Several commands in the input can be separated by semicolons ({{Code|;}}).* If the specified input is a valid URL URI or file reference, this file will be is evaluated as [[Commands#Command_Scripts|Command Script]].|||• {{Code|-c list}}<br/>• {{Code|-ccommands.txt}}<br/>• {{Code|-c"<info/>"}}|- valign="top"| {{Code|-C<file>}}| Evaluates the contents of the specified file as [[Commands#Command_Scripts|Command Script]].|
|
|
|• {{Code|-c"list;info"}}<br/>• {{Code|-ccommands.txt}}<br/>• {{Code|-c"<info/>"}}
|- valign="top"
| {{Code|-d}}
| Toggles the debugging mode. Debugging information is output to ''standard error''.
| <code>[[Options#DEBUG{{Option|DEBUG]]</code>}}
| <code>false</code>
|
|- valign="top"
| {{Code|-i<input>}}
| Opens an the specified XML file , directory with XML files, or database specified by the argument. The opened input can then be processed by a command or XQuery expression.
|
|
|- valign="top"
| {{Code|-q<expr>}}
| Executes Evaluates the specified string as XQuery expression.
|
|
| {{Code|-q"doc('input')//head"}}
|- valign="top"
| {{Code|-Q<file>}}
| Evaluates the contents of the specified file as XQuery expression.
|
|
|
|- valign="top"
| {{Code|-r<num>}}
| Specifies how often a specified query will be evaluated.
| <code>[[Options#RUNS{{Option|RUNS]]</code>}}
| <code>1</code>
| {{Code|-V -r10 "1"}}
|- valign="top"
| {{Code|-R}}
| Specifies if a query will be executed evaluated or parsed and compiled only.| <code>[[Options#RUNQUERY{{Option|RUNQUERY]]</code>}}
| <code>true</code>
| {{Code|-V -R "1"}}
| {{Code|-s<args>}}
| Specifies parameters for serializing XQuery results; see [[Serialization]] for more details. This flag may be specified multiple times. Key and values are separated by the equality sign (<code>=</code>).
| <code>[[Options#SERIALIZER{{Option|SERIALIZER]]</code>}}
|
| <code>-smethod=text</code>
| {{Code|-u}}
| Propagates updates on input files back to disk.
| <code>[[Options#WRITEBACK{{Option|WRITEBACK]]</code>}}
| <code>false</code>
|
| {{Code|-V}}
| Prints detailed query information to the ''standard output'', including details on the compilation and profiling steps.
| <code>[[Options#QUERYINFO{{Option|QUERYINFO]]</code>}}
| <code>false</code>
|
|- valign="top"
| {{Code|-w}}
| Toggles whitespace chopping stripping of XML text nodes. By default, whitespaces will be choppedpreserved.| {{Option|STRIPWS}}| <code>[[Options#CHOP|CHOP]]false</code>||- valign="top"| {{Code|-W}}| Enables indentation with whitespace. By default, query results will not be indented.| {{Option|SERIALIZER}}| <code>trueindent=no</code>
|
|- valign="top"
| {{Code|-x}}
| Toggles the output of the query execution plan, formatted as [[Options#XMLPLAN|XML]].| <code>[[Options#XMLPLAN{{Option|XMLPLAN]]</code>}}
| <code>false</code>
|
|- valign="top"
| {{Code|-X}}
| Generates the query plan before or after query compilation. {{Code|-x}} needs to be activated to make the plan visible.
| <code>[[Options#COMPPLAN|COMPPLAN]]</code>
| <code>true</code>
|
|- valign="top"
| {{Code|-z}}
| Turns the serialization of XQuery results on/off. This flag is useful if the query is profiled or analyzed.
| <code>[[Options#SERIALIZE{{Option|SERIALIZE]]</code>}}
| <code>true</code>
|
=GUI=
;Launch the GUI:
The <code>basexgui</code> command has only one option. You can pass one or more XML and XQuery files as parameters. If an XML file is specified, a database instance is created from this file, or an existing database is opened. XQuery files following options are opened in available for the XQuery editor.standalone [[GUI|Graphical User Interface]]:
<pre>
$ basexgui -hBaseX [fileGUI]Usage: basexgui [-d] [files] [files] Open specified files -d Enable debugging
</pre>
You can pass one or more files as parameters. If an XML document is specified, a database instance can be created from this file. Other files are opened in the editor.
=Server=
;Launch the server{{Announce|Added with Version 11:}} {{Code|-C}}<pre>$ basexserverBaseX The following options are available for the [[Database Server]Server was started (port]: 1984)</pre>
Available command-line flags can be listed with {{Code|-h}}:
<pre>
$ basexserver -h
stop Stop running server
-c<input> Execute commands from file or string
-C<file> Execute command script file
-d Enable debugging output
-n<name> Set host the server is bound to
</pre>
The flags have Details on all options are listed in the following meaning table (equivalent database options are shown in the table as well).For the examples to work escaping some characters , it might be necessary, to escape some characters depending on your Operating Systemoperating system.
{| class="wikitable"
|- valign="top"
| {{Code|-c<input>}}
| Executes [[commands]]:* Several commands in the input can be separated by semicolons ({{Code|;}}).* If the specified input is a valid URL URI or file reference, this file will be is evaluated as [[Commands#Command_Scripts|Command Script]].
|
|
| {{Code|-c"open database;info"}}
|- valign="top"
| {{Code|-C<file>}}
| Evaluates the contents of the specified file as [[Commands#Command_Scripts|Command Script]].
|
|
|
|- valign="top"
| {{Code|-d}}
| Turns on the Enables debugging modeoutput. Debugging information is output to ''standard error''.| <code>[[Options#DEBUG{{Option|DEBUG]]</code>}}
| <code>false</code>
|
| {{Code|-n<name>}}
| Specifies the host the server will be bound to.
| <code>[[Options#SERVERHOST{{Option|SERVERHOST]]</code>}}
|
| {{Code|-p127.0.0.1}}
| {{Code|-p<port>}}
| Specifies the port on which the server will be addressable.
| <code>[[Options#SERVERPORT{{Option|SERVERPORT]]</code>}}
| {{Code|1984}}
| {{Code|-p9999}}
| {{Code|-z}}
| Prevents the generation of [[Logging|log files]].
| <code>[[Options#LOG{{Option|LOG]]</code>}}
| <code>true</code>
|
=Client=
;Launch the console mode communicating {{Announce|Added with the serverVersion 11:}} {{Code|-C}}, {{Code|-Q}}, {{Code|-W}}
The user name and password If the [[Database Server|Database Client]] is launched, you will be requested. The default user/for a username and password combination is '''admin'''/'''admin''':<pre>$ basexclientUsername: adminPassword: *****BaseX [Client]Try "help" to get more information.> _</pre>
Available command-line flags can be listed with {{Code|-h}}:
<pre>
$ basexclient -h
-b<args> Bind external query variables
-c<input> Execute commands from file or string
-C<file> Execute command script file
-d Toggle debugging output
-i<input> Bind file or database to context
-P<pass> Specify user password
-q<expr> Execute XQuery expression
-Q<file> Execute XQuery file
-r<num> Run query multiple times
-R Toggle query execution
-s<args> Set serialization parameters
-U<name> Specify user nameusername
-v Toggle output of progress info
-V Toggle detailed query output
-w Toggle whitespace choppingstripping -W Enable indentation with whitespaces
-x Toggle output of query plan
-z Toggle output of query result
</pre>
The flags have See the following meaning table for details (equivalent database options are shown in the table as well).For the examples to work escaping some characters , it might be necessaryto escape some characters, depending on your Operating Systemoperating system.
{| class="wikitable"
|- valign="top"
| {{Code|-b<args>}}
| Binds external variables to XQuery expressions. This flag may be specified multiple times. Variables names and their values are delimited by equality signs (<code>=</code>). The names may be optionally prefixed with dollar signs. If a variable uses a namespace different to from the default namespace, it can be specified with the [http://www.jclark.com/xml/xmlns.htm Clark Notation] or [http://wwwXQuery 3.w3.org/TR/xquery-30/0#id-basics Expanded QName NotationQNames|Expanded QNames]]notation.| <code>[[Options#BINDINGS{{Option|BINDINGS]]</code>}}
|
|• <code>-b$v=example "declare variable $v external; $v"</code><br/>• <code>-bbQ{URL}ln=value<br/>"declare namespace ns='URL'; declare variable $ns:ln external; $ns:ln"</code>
|- valign="top"
| {{Code|-c<input>}}
| Executes [[commands]]:* Several commands in the input can be separated by semicolons ({{Code|;}}).* If the specified input is a valid URI or file reference or URL, its content will be executed instead. Empty lines and lines starting with the number sign {{Code|#}} will be ignored.|||• {{Code|-c list}}<br/>• {{Code|-ccommands.txt}}<br/>• {{Code|-c"<info/>"}}|- valign="top"| {{Code|-C<file>}}| Evaluates the contents of the specified file as [[Commands#Command_Scripts|Command Script]].|
|
|
|• {{Code|-c"list;info"}}<br/>• {{Code|-ccommands.txt}}<br/>• {{Code|-c"<info/>"}}
|- valign="top"
| {{Code|-d}}
| Toggles the debugging mode. Debugging information is output to ''standard error''.
| <code>[[Options#DEBUG{{Option|DEBUG]]</code>}}
| <code>false</code>
|
|- valign="top"
| {{Code|-i<input>}}
| Opens an the specified XML file , directory with XML files, or database specified by the argument. The opened input can then be processed by a command or XQuery expression.
|
|
| {{Code|-n<name>}}
| Specifies the host name on which the server is running.
| <code>[[Options#HOST{{Option|HOST]]</code>}}
| {{Code|localhost}}
| {{Code|-nserver.basex.org}}
| {{Code|-p<port>}}
| Specifies the port on which the server is running.
| <code>[[Options#PORT{{Option|PORT]]</code>}}
| {{Code|1984}}
| {{Code|-p9999}}
|- valign="top"
| {{Code|-P<pass>}}
| Specifies the user password. If this flag is omitted, the password will be requested on command line. ''Warning'': when When the password is specified supplied with this flag, it may get visible to othersend up in logs or the bash history.| <code>[[Options#PASSWORD{{Option|PASSWORD]]</code>}}
|
| {{Code|-Uadmin -PadminP...}}
|- valign="top"
| {{Code|-q<expr>}}
| Executes the specified string as XQuery expression.
|
| {{Code|-q"doc('input')//head1+2"}}|- valign="top"| {{Code|-Q<file>}}| Evaluates the contents of the specified file as XQuery expression.|||
|- valign="top"
| {{Code|-r<num>}}
| Specifies how often a specified query will be evaluated.
| <code>[[Options#RUNS{{Option|RUNS]]</code>}}
| <code>1</code>
| {{Code|-V -r10 "1"}}
| {{Code|-R}}
| Specifies if a query will be executed or parsed only.
| <code>[[Options#RUNQUERY{{Option|RUNQUERY]]</code>}}
| <code>true</code>
| {{Code|-V -R "1"}}
| {{Code|-s<args>}}
| Specifies parameters for serializing XQuery results; see [[Serialization]] for more details. This flag may be specified multiple times. Key and values are separated by the equality sign (<code>=</code>).
| <code>[[Options#SERIALIZER{{Option|SERIALIZER]]</code>}}
|
| <code>-smethod=text</code>
|- valign="top"
| {{Code|-U<name>}}
| Specifies the user nameusername. If this flag is omitted, the user name username will be requested on command line.| <code>[[Options#USER{{Option|USER]]</code>}}
|
| {{Code|-Uadmin}}
| {{Code|-V}}
| Prints detailed query information to the ''standard output'', including details on the compilation and profiling steps.
| <code>[[Options#QUERYINFO{{Option|QUERYINFO]]</code>}}
| <code>false</code>
|
|- valign="top"
| {{Code|-w}}
| Toggles whitespace chopping stripping of XML text nodes. By default, whitespaces will be choppedpreserved.| {{Option|STRIPWS}}| <code>[[Options#CHOP|CHOP]]false</code>||- valign="top"| {{Code|-W}}| Enables indentation with whitespace. By default, query results will not be indented.| {{Option|SERIALIZER}}| <code>chopindent=no</code>
|
|- valign="top"
| {{Code|-x}}
| Toggles the output of the query execution plan, formatted as [[Options#XMLPLAN|XML]].| <code>[[Options#XMLPLAN{{Option|XMLPLAN]]</code>}}
| <code>false</code>
|
|- valign="top"
| {{Code|-X}}
| Generates the query plan before or after query compilation. {{Code|-x}} needs to be activated to make the plan visible.
| <code>[[Options#COMPPLAN|COMPPLAN]]</code>
| <code>after</code>
|
|- valign="top"
| {{Code|-z}}
| Turns the serialization of XQuery results on/off. This flag is useful if the query is profiled or analyzed.
| <code>[[Options#SERIALIZE{{Option|SERIALIZE]]</code>}}
| <code>true</code>
|
=HTTP Server=
;Launch the HTTP server{{Announce|Added with Version 11:}} {{Code|-C}}<pre>$ basexhttpBaseX The following options are available for the [[Web Application|HTTP Server]Server was started (port]: 1984)HTTP Server was started (port: 8984)</pre>
Available command-line flags can be listed with {{Code|-h}}:
<pre>
$ basexhttp -h
stop Stop running server
-c<input> Execute commands from file or string
-C<file> Execute command script file
-d Enable debugging output
-g Enable GZIP support
-h<port> Set port of HTTP server
-l Start in local mode
-s<port> Specify port to stop HTTP server
-S Start as service
-U<name> Specify user nameusername
-z Suppress logging
</pre>
The flags have meaning of all options is listed in the following meaning table (equivalent database options are shown in the table as well).For the examples to work escaping some characters , it might be necessary, to escape some characters depending on your Operating System.
{| class="wikitable"
|- valign="top"
| {{Code|-c<input>}}
| Executes [[commands]]:* Several commands in the input can be separated by semicolons ({{Code|;}}).* If the specified input is a valid URL URI or file reference, this file will be is evaluated as [[Commands#Command_Scripts|Command Script]].
|
|
| {{Code|-c"open database"}}
|- valign="top"
| {{Code|-dC<file>}}| Turns on Evaluates the contents of the specified file as [[Commands#Command_Scripts|Command Script]].||||- valign="top"| {{Code|-e}}| Enables debugging modeoutput. Debugging information is output to ''standard error''.| <code>[[Options#{{Option|DEBUG}}|DEBUG]]</code>||- valign="top"| {{Code|-g}}| Enables GZIP support in Jetty.| {{Option|GZIP}}
|
|
| Specifies the port on which the HTTP server will be addressable.
| <code>jetty.xml</code>
| {{Code|89848080}}
| {{Code|-h9999}}
|- valign="top"
| {{Code|-l}}
| Starts the server in ''local mode'', and executes all commands in the embedded database context.
| <code>[[Options#HTTPLOCAL{{Option|HTTPLOCAL]]</code>}}
|
|
| {{Code|-n<name>}}
| Specifies the host name on which the server is running.
| <code>[[Options#HOST{{Option|HOST]]</code>}}
| {{Code|localhost}}
| {{Code|-nserver.basex.org}}
| {{Code|-p<port>}}
| Specifies the port on which the database server will be addressable.
| <code>[[Options#SERVERPORT{{Option|SERVERPORT]]</code>}}
| {{Code|1984}}
| {{Code|-p9998}}
| {{Code|-s<port>}}
| Specifies the port that will be used to stop the HTTP server.
| <code>[[Options#STOPPORT{{Option|STOPPORT]]</code> }} or<br/><code>pom.xml</code>| <code>89858081</code>
|
|- valign="top"
|- valign="top"
| {{Code|-U<name>}}
| Specifies a user nameusername, which will be used by the HTTP services for opening a new session.| <code>[[Options#USER{{Option|USER]]</code>}}
|
| {{Code|-Uadmin}}
| {{Code|-z}}
| Prevents the generation of [[Logging|log files]].
| <code>[[Options#LOG{{Option|LOG]]</code>}}
|
|}
=Changelog=
;Version 11.0
* Added: {{Code|-C}} (standalone, server, client, HTTP server).
* Added: {{Code|-Q}}, {{Code|-W}} (standalone, client).
* Updated: The Clark notation was replaced with the [[XQuery 3.0#Expanded QNames|Expanded QNames]] notation.
;Version 10.0
* Updated: Whitespaces are now preserved by default (see {{Option|STRIPWS}} for more details).
;Version 9.0
* Added: BaseXHTTP, command-line option {{Code|-c}}.
* Updated: BaseXHTTP, command-line option {{Code|-c}}, additionally accepts valid URLs and file references.
;Version 8.2
* Removed: Event ports, {{Code|-e}}.
;Version 8.1
* Added: Bind input strings to the query context with {{Code|-I}}.
;Version 8.0
* Removed: Command-line option <code>-L</code> (results will now be automatically separated by newlines).
;Version 7.9
* Added: Runs tests in file or directory with {{Code|-t}}.
* Removed: interactive server mode.
;Version 7.8
* Added: Specify if a query will be executed or parsed only with {{Code|-R}}.
;Version 7.7
* Added: Bind host to the [[#BaseX Server|BaseX Server]] with {{Code|-n}}.
;Version 7.5
* Added: detection of [[Commands#Basics|Command Scripts]].
* Removed: HTTP server flags {{Code|-R}}, {{Code|-W}}, and {{Code|-X}}.
; Version 7.3:
* Updated: all options are now evaluated in the given order.
* Updated: Create main-memory representations for specified sources with {{Code|-i}}.
; Version 7.2:
* Added: RESTXQ Service
; Version 7.1.1:
* Added: Options {{Code|-C}} and {{Code|-L}} in standalone and client mode.
; Version 7.1:
* Updated: Multiple query files and {{Code|-c}}/{{Code|-i}}/{{Code|-q}} flags can be specified.