Changes

Jump to navigation Jump to search
833 bytes removed ,  13:59, 11 July 2019
no edit summary
This article is part of the [[Getting Started]] Guide.
It gives more details on the command-line options of all Each BaseX [[Startup]] modesmode has one or more command-line options which are described in this article.
Options Command-line options can be specified multiple times. All Please note that all options are will be evaluated in the given order (in earlier versions, the sequential evaluation was limited to the specified inputs, query files, queries and commands, while all other options were initially set). The standard input can be parsed by specifying a single dash ({{Code|-}}) as argument.
=BaseX Standalone= ;Launch the standalone (console ) mode:
<pre>
$ basex
> _</pre>
Available You can list the command-line flags can be listed with options available for the standalone mode using {{Code|-h}}:
<pre>
$ basex -h
BaseX [Standalone]
Usage: basex [-bcdiLoqrRsuvVwxXzbcdiIoqrRstuvVwxz] [input] [input] Execute input XQuery or command file , or expressionquery string -b<parsargs> Bind external query variables -c<input> Execute commands from file or string -d Activate Toggle debugging modeoutput -i<input> Open initial Bind file or databaseto context -L Append newlines I<input> Bind input string to query resultscontext -o<outputpath> Write output to local file -q<expr> Execute XQuery expression -r<num> Set number of Run query executionsmultiple times -R Turn Toggle query execution on/off -s<parsargs> Set serialization parameter(s)parameters -t[path] Run tests in file or directory -u Write Toggle updates back to in original files -v/V Show (all) process Toggle output of progress info -w Preserve whitespaces from input filesV Toggle detailed query output -x Show query execution planw Toggle whitespace chopping -X Show x Toggle output of query plan before/after compilation -z Skip Toggle output of resultsquery result
</pre>
The meaning of all flags options is listed in the following table. If an equivalent database option exists (which can be specified via the <code>[[Commands#SET|SET]] </code> command), it is listed 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"
! width='120' | Flag
| {{Code|[input]}}
|Evaluates the specified input:
* The input string may point to an existing file. If the file suffix is {{Code|.bxs}}, the file content contents will be evaluated as [[Commands#Basics|Command Script]]; otherwise, it any other file content will be evaluated as XQuery expression.
* Otherwise, the input string itself is evaluated as XQuery expression.
|
|• {{Code|"doc('X')//head"}}<br/>• {{Code|query.xq}}<br/>• {{Code|commands.bxs}}<br/>
|- valign="top"
| {{Code|-b&lt;parsargs&gt;}}
| 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 the default namespace, it can be specified with the [http://www.jclark.com/xml/xmlns.htm Clark Notation].
| <code>[[Options#BINDINGS{{Option|BINDINGS]]</code>}}
|
|• <code>-b$vbv=example "declare variable $v external; $v"</code><br/>• <code>-b{URL}ln=value<br/>"declare namespace ns='URL'; declare variable $ns:ln external; $ns:ln"</code>
|- valign="top"
| {{Code|-c&lt;input&gt;}}
| Executes [[Commandscommands]]:* 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 this file will be executed instead. Empty lines and lines starting with the number sign {{Codeevaluated as [[Commands#Command_Scripts|#}} will be ignoredCommand 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&lt;input&gt;}}
| Opens a the specified XML file, directory with XML files, or database or XML document specified by the argument. The opened input may can then be further processed by an a command or XQuery expression.
|
|
| {{Code|-iitems.xml "//item"}}
|- valign="top"
| {{Code|-LI&lt;input&gt;}}| Separates returned query items by newlines (instead Assigns an input string as item of spaces) and appends a newline type {{Code|xs:untypedAtomic}} to the end of a resultquery context.|
|
|
| {{Code|-I "Hello Universe" -q "."}}
|- valign="top"
| {{Code|-o&lt;filepath&gt;}}
| All command and query output is written to the specified file.
|
| {{Code|-r&lt;num&gt;}}
| 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"}}
|- valign="top"
| {{Code|-s&lt;parsargs&gt;}}
| 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|-t[path]}}| Runs all [[Unit Module|Unit tests]] in the specified file or directory. {{Mark|Introduced with Version 7.9}}| |
| -t project/tests
|- valign="top"
| {{Code|-u}}
| Propagates updates on input files back to disk.
| <code>[[Options#WRITEBACK{{Option|WRITEBACK]]</code>}}
| <code>false</code>
|
|- valign="top"
| {{Code|-v}}
| Prints Toggles the output of process and timing information to the ''standard output''.
|
| <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}}
| Specifies if whitespaces in Toggles whitespace chopping of XML text nodes should . By default, whitespaces will be chopped (which is the default) or preserved.| <code>[[Options#CHOP{{Option|CHOP]]</code>}}
| <code>true</code>
|
|- valign="top"
| {{Code|-x}}
| This flags turn on Toggles the output of the query execution plan, formatted in [[Options#XMLPLANas {{Option|XML]]}}.| <code>[[Options#XMLPLAN{{Option|XMLPLAN]]</code>}}
| <code>false</code>
|
|- valign="top"
| {{Code|-X}}
| Creates Generates the query plan before or after query compilation. {{Code|-x}} needs to be activated to make the plan visible.| <code>[[Options#COMPPLAN{{Option|COMPPLAN]]</code>}}
| <code>true</code>
|
| {{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>
|
|}
=BaseX 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 are opened in the XQuery editor. <pre>$ basexgui [file]</pre> =Server= 
;Launch the server
<pre>
</pre>
Available You can list the available command-line flags can be listed with options using {{Code|-h}}:
<pre>
$ basexserver -h
BaseX [Server]
Usage: basexserver [-cdeinpSzcdnpSz] [stop] stop Stop running server -c<cmdsinput> Execute initial database commandsfrom file or string -d Activate Enable debugging mode -e<port> Set event portoutput -n<name> Set host the server is bound to -p<port> Set server port -S Start as service -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"
! width='120' | Flag
|- valign="top"
| {{Code|stop}}
| Stops an existing a local database server instance and quits.
|
|
|- valign="top"
| {{Code|-c&lt;cmdinput&gt;}}| Launches database Executes [[commands before ]]. If the server itself specified input is started. Several commands can a valid URI or file reference, this file will be separated by semicolons ({{Codeevaluated as [[Commands#Command_Scripts|;}})Command Script]].
|
|
| {{Code|-d}}
| Turns on the debugging mode. Debugging information is output to ''standard error''.
| <code>[[Options#DEBUG{{Option|DEBUG]]</code>}}
| <code>false</code>
|
|- valign="top"
| {{Code|-e&lt;num&gt;}}
| Specifies the port on which the server will send events to clients.
| <code>[[Options#EVENTPORT|EVENTPORT]]</code>
| {{Code|1985}}
| {{Code|-e9998}}
|- valign="top"
| {{Code|-n&lt;name&gt;}}
| Specifies the host the server will be bound to.
| <code>[[Options#SERVERHOST{{Option|SERVERHOST]]</code>}}
|
| {{Code|-p127.0.0.1}}
|- valign="top"
| {{Code|-p&lt;numport&gt;}}
| Specifies the port on which the server will be addressable.
| <code>[[Options#SERVERPORT{{Option|SERVERPORT]]</code>}}
| {{Code|1984}}
| {{Code|-p9999}}
|- valign="top"
| {{Code|-S}}
| Starts the server as service (i.e., in the background).Use [[YAJSW]], or start BaseX as an ordinary background process to get more options.|
|
|
|- valign="top"
| {{Code|-z}}
| Does not generate any Prevents the generation of [[Logging|log files]].| <code>[[Options#LOG{{Option|LOG]]</code>}}
| <code>true</code>
|
|}
Multiple {{Code|-c}} and {{Code|-i}} flags can be specified. All other options will be set before any other operation takes place. The specified inputs, query files, queries and commands will be subsequently evaluated after that in the given order. The standard input can be parsed by specifying a single dash ({{Code|-}}) as argument.
=BaseX Client=
;Launch the console mode communicating with the server
</pre>
Available You can list the available command-line flags can be listed with options using {{Code|-h}}:
<pre>
$ basexclient -h
BaseX [Client]
Usage: basexclient [-bcdiLnopPqrRsUvVwxXzbcdiInopPqrRsUvVwxz] [input] [input] Execute input XQuery or command file , or expressionquery string -b<parsargs> Bind external query variables -c<input> Execute commands from file or string -d Activate Toggle debugging modeoutput -i<input> Open initial Bind file or databaseto context -L Append newlines I<input> Bind input string to query resultscontext -n<name> Set server (host) name -o<outputpath> Write output to local file -p<port> Set server port -P<pass> Specify user password -q<expr> Execute XQuery expression -r<num> Set number of Run query executionsmultiple times -R Turn Toggle query execution on/off -s<parsargs> Set serialization parameter(s)parameters -U<name> Specify user name -v/V Show (all) process Toggle output of progress info -w Preserve whitespaces from input filesV Toggle detailed query output -x Show query execution planw Toggle whitespace chopping -X Show x Toggle output of query plan before/after compilation -z Skip Toggle output of resultsquery result
</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"
! width='120' | Flag
| {{Code|[input]}}
|Evaluates the specified input:
* The input string may point to an existing file. If the file suffix is {{Code|.bxs}}, the file content contents will be evaluated as [[Commands#Basics|Command Script]]; otherwise, it any other file content will be evaluated as XQuery expression.
* Otherwise, the input string itself is evaluated as XQuery expression.
|
|• {{Code|"doc('X')//head"}}<br/>• {{Code|query.xq}}<br/>• {{Code|commands.bxs}}<br/>
|- valign="top"
| {{Code|-b&lt;parsargs&gt;}}
| 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 the default namespace, it can be specified with the [http://www.jclark.com/xml/xmlns.htm Clark Notation] or [http://www.w3.org/TR/xquery-30/#id-basics Expanded QName Notation].
| <code>[[Options#BINDINGS{{Option|BINDINGS]]</code>}}
|
|• <code>-b$v=example "declare variable $v external; $v"</code><br/>• <code>-b{URL}ln=value<br/>"declare namespace ns='URL'; declare variable $ns:ln external; $ns:ln"</code>
|- valign="top"
| {{Code|-c&lt;input&gt;}}
| Executes [[Commandscommands]]:* 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;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&lt;input&gt;}}
| Opens a the specified XML file, directory with XML files, or database or XML document specified by the argument. The opened input may can then be further processed by an a command or XQuery expression.
|
|
| {{Code|-iitems.xml "//item"}}
|- valign="top"
| {{Code|-LI&lt;input&gt;}}| Separates returned query items by newlines (instead Assigns an input string as item of spaces) and appends a newline type {{Code|xs:untypedAtomic}} to the end of a resultquery context.
|
|
| {{Code|-I "Hello Universe" -q "."}}
|- valign="top"
| {{Code|-n&lt;name&gt;}}
| Specifies the host name on which the server is running.
| <code>[[Options#HOST{{Option|HOST]]</code>}}
| {{Code|localhost}}
| {{Code|-nserver.basex.org}}
|- valign="top"
| {{Code|-o&lt;filepath&gt;}}
| All command and query output is written to the specified file.
|
|
|- valign="top"
| {{Code|-p&lt;numport&gt;}}
| Specifies the port on which the server is running.
| <code>[[Options#PORT{{Option|PORT]]</code>}}
| {{Code|1984}}
| {{Code|-p9999}}
| {{Code|-P&lt;pass&gt;}}
| Specifies the user password. If this flag is omitted, the password will be requested on command line. ''Warning'': when the password is specified with this flag, it may get visible to others.
| <code>[[Options#PASSWORD{{Option|PASSWORD]]</code>}}
|
| {{Code|-Uadmin -Padmin}}
| Executes the specified string as XQuery expression.
|
| {{Code|-q"doc('input')//head1+2"}}
|- valign="top"
| {{Code|-r&lt;num&gt;}}
| 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"}}
|- valign="top"
| {{Code|-s&lt;parsargs&gt;}}
| 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&lt;name&gt;}}
| Specifies the user name. If this flag is omitted, the user name 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}}
| Specifies if whitespaces in Toggles whitespace chopping of XML text nodes should . By default, whitespaces will be chopped (which is the default) or preserved.| <code>[[Options#CHOP{{Option|CHOP]]</code>}}
| <code>chop</code>
|
|- valign="top"
| {{Code|-x}}
| This flags turn on Toggles the output of the query execution plan, formatted in [[Options#XMLPLANas {{Option|XML]]}}.| <code>[[Options#XMLPLAN{{Option|XMLPLAN]]</code>}}
| <code>false</code>
|
|- valign="top"
| {{Code|-X}}
| Creates Generates the query plan before or after query compilation. {{Code|-x}} needs to be activated to make the plan visible.| <code>[[Options#COMPPLAN{{Option|COMPPLAN]]</code>}}
| <code>after</code>
|
| {{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>
|
|}
=BaseX HTTP Server=
;Launch the HTTP server:
</pre>
Available You can list the available command-line flags can be listed with options using {{Code|-h}}:
<pre>
$ basexhttp -h
BaseX [HTTP]
Usage: basexhttp [-dehlnpPRUWzcdhlnpsSUz] [stop] stop Stop running server -d Activate debugging modec<input> Execute commands from file or string -e<port> Set event portd Enable debugging output -h<port> Set port of HTTP server -l Start in local mode -n<name> Set host name of database server -p<port> Set port of database server -P<pass> Specify user password -s<port> Specify port to stop HTTP server -S Start as service -U<name> Specify user name -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"
! width='120' | Flag
|- valign="top"
| {{Code|stop}}
| Stops a running local HTTP serverand quits. By default, the The database server will be stopped as well, unless {{Code|-l}} has been is specified.
| <code>pom.xml</code>
|
|
|- valign="top"
| {{Code|-c&lt;input&gt;}}
| Executes [[commands]]. If the specified input is a valid URI or file reference, this file will be evaluated as [[Commands#Command_Scripts|Command Script]].
|
|
| {{Code|-c"open database"}}
|- valign="top"
| {{Code|-d}}
| Turns on the debugging mode. Debugging information is output to ''standard error''.
| <code>[[Options#DEBUG{{Option|DEBUG]]</code>}}
|
|
|- valign="top"
| {{Code|-eh&lt;num&gt;}}| Specifies the port on which the server will send events to clients.| <code>[[Options#EVENTPORT|EVENTPORT]]</code>| {{Code|1985}}| {{Code|-e9998}}|- valign="top"| {{Code|-h&lt;num&gt;}}
| Specifies the port on which the HTTP server will be addressable.
| <code>jetty.xml</code>
| {{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&lt;name&gt;}}
| Specifies the host name on which the server is running.
| <code>[[Options#HOST{{Option|HOST]]</code>}}
| {{Code|localhost}}
| {{Code|-nserver.basex.org}}
|- valign="top"
| {{Code|-p&lt;numport&gt;}}
| Specifies the port on which the database server will be addressable.
| <code>[[Options#SERVERPORT{{Option|SERVERPORT]]</code>}}
| {{Code|1984}}
| {{Code|-p9998}}
|- valign="top"
| {{Code|-Ps&lt;passport&gt;}}| Specifies a user password, which the port that will be used by to stop the HTTP services to open a new sessionserver. If this flag is omitted, and if | {{CodeOption|-USTOPPORT}} was specified, the password will be requested on command line. ''Warning'': when the password is specified with this flag, it may get visible to othersor<br/><code>pom.xml</code>| <code>[[Options#PASSWORD|PASSWORD]]8985</code>
|
| {{Code|-Uadmin -Padmin}}
|- valign="top"
| {{Code|-s&lt;num&gt;}}
| Specifies the port that will be used to stop the HTTP server.
| <code>[[Options#STOPPORT|STOPPORT]]</code> or<br/><code>pom.xml</code>
| <code>8983</code>
|
|- valign="top"
| {{Code|-S}}
| Starts the server as service (i.e., in the background).Use [[YAJSW]], or start BaseX as an ordinary background process to get more options.|
|
|
|- valign="top"
| {{Code|-U&lt;name&gt;}}
| Specifies a user name, which will be used by the HTTP services for opening a new session.
| <code>[[Options#USER{{Option|USER]]</code>}}
|
| {{Code|-Uadmin}}
|- valign="top"
| {{Code|-z}}
| Does not generate any Prevents the generation of [[Logging|log files]].| <code>[[Options#LOG{{Option|LOG]]</code>}}|
|}
=BaseX GUIChangelog;Version 9.0 * Added: BaseXHTTP, command-line option {{Code|-c}}.* Updated: BaseXHTTP, command-line option {{Code|-c}}, additionally accepts valid URLs and file references. ;Launch the GUIVersion 8.2 * Removed:Event ports, {{Code|-e}}.<pre>$ basexgui [file];Version 8.1 </pre>* Added: Bind input strings to the query context with {{Code|-I}}.
One or more XML and XQuery files can be passed on as parameters. If an XML file is specified, a database instance is created from this file, or an existing database is opened. XQuery files are opened in the XQuery editor;Version 8.0
=Changelog=* Removed: Command-line option <code>-L</code> (results will now be automatically separated by newlines).
;Version 7.9
* Updated: Multiple query files and {{Code|-c}}/{{Code|-i}}/{{Code|-q}} flags can be specified.
 
[[Category:Beginner]]
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu