| basex(1) | The XML Database | basex(1) |
basex - XML database system and XPath/XQuery processor (command line mode)
basex [-bcdiIoqrRstuvVwxz] [input]
basex is a fast and powerful, yet light-weight and platform independent XML database system and XPath/XQuery processor.
A short description of option can be obtained from
$ basex -hor by browsing https://docs.basex.org/wiki/Command-Line_Options#Standalone
A list of supported Database commands can be obtained from
$ basex -c helpor by browsing https://docs.basex.org/wiki/Commands
$ basex 19+23
42
$ basex -q "<answer>{ 23+19 }</answer>"
<answer>42</answer>
$ basex -Vc "CREATE DB input /usr/share/doc/basex/examples/input.xml; XQUERY /"
Database 'input' created in 136.84 ms.
<html>
<!-- Header -->
<head id="0">
<title>XML</title>
</head>
<!-- Body -->
<body id="1" bgcolor="#FFFFFF" text="#000000" link="#0000CC">
<h1>Databases & XML</h1>
<div align="right">
<b>Assignments</b>
<ul>
<li>Exercise 1</li>
<li>Exercise 2</li>
</ul>
</div>
</body>
<?pi bogus?>
</html>
Query: /
Compiling:
Result: root()
Parsing: 5.08 ms
Compiling: 27.2 ms
Evaluating: 0.87 ms
Printing: 13.7 ms
Total Time: 46.86 ms
Hit(s): 1 Item
Updated: 0 Items
Printed: 358 Bytes
Query executed in 42.52 ms.
$ basex -c "OPEN input; XQUERY //li[1]"
<li>Exercise 1</li>
$ basex -q "doc('https://files.basex.org/examples/input.xml')//li"
<li>Exercise 1</li>
<li>Exercise 2</li>
$ basex
BaseX 7.1 [Standalone]
Try "help" to get more information.
> SET FTINDEX on
Full-Text Index: ON
> CREATE DB input /usr/share/doc/basex/examples/input.xml
Database 'input' created in 94.42 ms.
> XQUERY //b[text() contains text 'Asisgnment' using fuzzy]
<b>Assignments</b>
Query executed in 8.37 ms.
> XQUERY delete node //ul
Query executed in 2.79 ms.
> XQUERY replace value of node //b with 'Debian rules'
Query executed in 2.94 ms.
> XQUERY //div
<div align="right">
<b>Debian rules</b>
</div>
Query executed in 1.01 ms.
$ basex -i /usr/share/doc/basex/examples/input.xml -q //div -o out.xml
$ cat out.xml
<div align="right">
<b>Assignments</b>
<ul>
<li>Exercise 1</li>
<li>Exercise 2</li>
</ul>
</div>
$ basex -i input -q //div
<div align="right">
<b>Assignments</b>
<ul>
<li>Exercise 1</li>
<li>Exercise 2</li>
</ul>
</div>
$ echo '19+23' | basex -q- 42
$ cat commands.txt create db debian <debian_db/> xquery / list $ basex -C commands.txt | grep debian <debian_db/> debian 1 4639 debian.xml
$ cat bad.html
<html>
<ul>
<li>A
<li>B
</ul>
</html>
$ basex -c 'set parser html; set htmlopt method=html,nons=true; create db htmldb bad.html'
$ basex -q "doc('htmldb')"
<html>
<body>
<ul>
<li>A</li>
<li>B</li>
</ul>
</body>
</html>
Alternative:
$ basex -q 'declare option db:parser "html"; doc("bad.html")'
<html xmlns="http://www.w3.org/1999/xhtml">
<body>
<ul>
<li>A</li>
<li>B</li>
</ul>
</body>
</html>
For further documentation on how to configure the HTML Parser refer to
https://docs.basex.org/wiki/Parsers#HTML_Parser
basexgui(1), basexserver(1), basexclient(1)
.basexhome can be created by a user to mark a folder as home directory.
.basex BaseX (standalone and server) properties
.basexgui BaseX additional GUI properties
.basexhistory contains commands that have been typed in most recently.
${basexhome}/data Default database directory
${basexhome}/data/.logs Server logs
${basexhome}/repo Package repository
BaseX Documentation Wiki: https://docs.basex.org
BaseX started as a research project of the Database and Information Systems Group (DBIS) at the University of Konstanz in 2005 and soon turned into a feature-rich open source XML database and XPath/XQuery processor.
New (3-clause) BSD License
BaseX is primarily developed by Christian Gruen <cg@basex.org> with the help of various contributors <https://basex.org/about/open-source/>
The man page was written by Alexander Holupirek <alex@holupirek.de> while packaging BaseX for Debian GNU/Linux.
| 19 April 2022 |