basex(1)

πŸ“¦
version 12.4 Β· 3 versions
, in ubuntu stonking

πŸ’– basex(1) β€” The XML Database πŸ’–

okay bestie, sit DOWN because we're talking about basex, from the manual page basex(1), and it is literally an icon. πŸ‘‘


✨ NAME ✨

basex β€” XML database system and XPath/XQuery processor (command line mode)

no cap, that's the whole name section and it already ate. πŸŽ€


🌸 SYNOPSIS 🌸

basex [-bcCdiIoOqQrRstuvVwWxz] [input]

that's it. that's the whole vibe. one little line and so many flags. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

basex is a fast and powerful, yet light-weight and platform independent XML database system and XPath/XQuery processor.

fast AND light AND works everywhere?? it's giving main character energy fr fr. 🌈


✨ OPTIONS ✨

so you wanna know what an option does? easiest thing ever, bestie. just run

$ basex -h

or, if you'd rather read it in your browser (valid, we love a cozy scroll), go browse https://docs.basex.org/main/Command-Line_Options#standalone

either way you get a short description of each option. no gatekeeping here. 🫢


πŸŽ€ DATABASE COMMANDS πŸŽ€

want the whole list of supported Database commands? say less:

$ basex -c help

or peek at https://docs.basex.org/main/Commands for the full menu. ✨


πŸ’œ EXAMPLES πŸ’œ

this is the part where it gets good. buckle up. πŸ“

  • XQuery evaluation (no database, no interaction, script mode):
$ basex 19+23
42
$ basex -q "<answer>{ 23+19 }</answer>"
<answer>42</answer>

look at that. it just... does math. and it's polite about it. πŸ˜­πŸ’–

  • Import an XML file into database, output its content (query its root) and be verbose:
$ basex -V -c "CREATE DB input /usr/share/doc/basex/examples/input.xml" -c "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 &amp; XML</h1>
    <div align="right">
      <b>Assignments</b>
      <ul>
        <li>Exercise 1</li>
        <li>Exercise 2</li>
      </ul>
    </div>
  </body>
  <?pi bogus?>
</html>

Query:
/

Optimizing:
- evaluate context value: . -> db:get-pre("input", 0)
- evaluate util:root(nodes): util:root(db:get-pre("input", 0)) -> db:get-pre("input", 0)

Optimized Query:
db:get-pre("input", 0)

Parsing: 1.94 ms
Compiling: 0.39 ms
Optimizing: 0.94 ms
Evaluating: 0.01 ms
Printing: 1.30 ms
Total Time: 4.58 ms

Hit(s): 1 Item
Updated: 0 Items
Printed: 358 b
Read Locking: input
Write Locking: (none)

Query executed in 4.58 ms.

verbose mode is so extra and we are obsessed. the timing breakdown?? the locking report?? iconic. πŸ”₯

  • XPath evaluation (with existing database):
$ basex -c "OPEN input; XQUERY //li[1]"
<li>Exercise 1</li>
  • Retrieve XML from the web and perform XPath query:
$ basex -q "doc('https://raw.githubusercontent.com/BaseXdb/basex/12.4/basex-core/src/test/resources/input.xml')//li"
<li>Exercise 1</li>
<li>Exercise 2</li>

yes it will just go get a URL for you. girlboss behaviour. 🌐

  • W3C XQuery Full-Text (make use of full-text index and perform fuzzy query with a typing error):
$ basex
BaseX 12.4 [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.

'Asisgnment' with a typo STILL found Assignments. the fuzzy search ate and left no crumbs. πŸ’…

  • Update the database and show result:
> 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.
  • Open an input xml file, execute a query and write result into file:
$ basex -i /usr/share/doc/basex/examples/input.xml -o out.xml -q //div
$ cat out.xml
<div align="right">
  <b>Assignments</b>
  <ul>
    <li>Exercise 1</li>
    <li>Exercise 2</li>
  </ul>
</div>
  • Query an already existing database called 'input'. If a file named 'input' exists in current working directory it takes precedence:
$ basex -i input -q //div
<div align="right">
  <b>Assignments</b>
  <ul>
    <li>Exercise 1</li>
    <li>Exercise 2</li>
  </ul>
</div>
heads up bestie: if there's a file literally named input sitting in your current working directory, it wins. file takes precedence over the database. don't get caught out. πŸ™ˆ
  • Let basex process query input from standard in:
$ echo '19+23' | basex -q-
42
  • Execute commands from script file:
$ cat commands.txt
create db debian <debian_db/>
xquery /
list
$ basex -C commands.txt | grep debian
<debian_db/>
debian              1          4639       debian.xml
  • Parse non well-formed HTML (needs libtagsoup-java installed):
$ cat bad.html
<html>
  <ul>
    <li>A
    <li>B
  </ul>
</html>

$ basex -c "SET PARSER html" -c "CREATE DB htmldb bad.html"
$ basex -q "doc('htmldb')"
<html>
  <body>
    <ul>
      <li>A</li>
      <li>B</li>
    </ul>
  </body>
</html>

Alternative (parse directly in a query, passing parser options):

$ basex -q 'fetch:doc("bad.html", map { "parser": "html" })'
<html>
  <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/main/Parsers#html_parser

genuinely so satisfying when broken HTML gets cleaned up like that. 🧚

🌈 SEE ALSO 🌈

basexgui(1), basexserver(1), basexclient(1)

and also, the files and folders that live in your BaseX life 🫢:

  • .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


⭐ HISTORY ⭐

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.

from uni research project to full glow-up. we love a come-up story. πŸ‘‘


πŸ’€ LICENSE πŸ’€

New (3-clause) BSD License


πŸŽ€ AUTHOR πŸŽ€

BaseX is primarily developed by Christian GrΓΌn <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.


and that's the whole page, bestie. this came out of The XML Database, version basex(1), dated 24 July 2026 β€” so when you see that footer, you know it's the real deal. now go forth and query something. slay. πŸ’–βœ¨πŸŒΈ

πŸ“¦ where this page comes from