Skip to content

Running with BaseX

Amanda Galtman edited this page Apr 11, 2024 · 13 revisions

Introduction

BaseX is an open source XML database engine and XPath/XQuery 3.1 processor. BaseX can be run as standalone, web application, database server, GUI application, etc.

Dependencies

Running XSpec tests with BaseX requires an XProc implementation. XML Calabash is used here as an example; follow these instructions to set up XML Calabash and store the XML Calabash jar file in a local directory (e.g. ~/xml/xmlcalabash for Linux/macOS or C:\xmlcalabash for Windows).

Run an XSpec test for XQuery with BaseX standalone

  1. Download the ZIP package of BaseX and extract it to a local directory (e.g. ~/xml/basex for Linux/macOS or C:\basex for Windows).

  2. Make sure a required version of Java Runtime Environment is installed, e.g.:

    java -version
  3. Make sure XSpec is available in a local path (e.g. ~/xml/xspec for Linux/macOS or C:\xspec for Windows).

  4. Navigate to your XSpec directory.

  5. Run an XSpec test for XQuery as follows:

    For Linux/macOS:

    java -jar ~/xml/xmlcalabash/xmlcalabash-1.2.5-99.jar \
         -i source=tutorial/xquery-tutorial.xspec \
         -p xspec-home=file:/home/myself/xml/xspec/ \
         -p basex-jar=/home/myself/xml/basex/BaseX.jar \
         -o result=tutorial/xquery-tutorial-result.html \
         src/harnesses/basex/basex-standalone-xquery-harness.xproc

    For Windows:

    java -jar C:\xmlcalabash\xmlcalabash-1.2.5-99.jar ^
         -i source=tutorial/xquery-tutorial.xspec ^
         -p xspec-home=file:///C:/xspec/ ^
         -p basex-jar=C:\basex\BaseX.jar ^
         -o result=tutorial/xquery-tutorial-result.html ^
         src\harnesses\basex\basex-standalone-xquery-harness.xproc

    where:

    • -cp is the classpath where XML Calabash is installed
    • -i source is the input port with the XSpec test for XQuery to be executed
    • -o result is the output port where the HTML report will be stored
    • -p xspec-home is the absolute URI of the XSpec installation
    • -p basex-jar is the jar file of BaseX
    • basex-standalone-xquery-harness.xproc is the XProc harness for BaseX standalone

The output result from the command line may look like this:

INFO : src/harnesses/harness-lib.xpl:267:45:passed: 1 / pending: 0 / failed: 0 / total: 1

And the HTML report file is created in the location specified by -o result=.

Run an XSpec test for XQuery with BaseX server

To run XSpec with BaseX server using its RESTful API, run XProc just like the steps with BaseX standalone but with these differences:

  • Instead of the basex-jar parameter, provide endpoint, username, password and auth-method
  • Instead of the basex-standalone-xquery-harness.xproc harness, use basex-server-xquery-harness.xproc

For Linux/macOS:

java -jar ~/xml/xmlcalabash/xmlcalabash-1.2.5-99.jar \
     -i source=tutorial/xquery-tutorial.xspec \
     -p xspec-home=file:/home/myself/xml/xspec/ \
     -p endpoint=http://localhost:8984/rest \
     -p username=admin \
     -p password=admin \
     -p auth-method=Basic \
     -o result=tutorial/xquery-tutorial-result.html \
     src/harnesses/basex/basex-server-xquery-harness.xproc

For Windows:

java -jar C:\xmlcalabash\xmlcalabash-1.2.5-99.jar ^
     -i source=tutorial/xquery-tutorial.xspec ^
     -p xspec-home=file:///C:/xspec/ ^
     -p endpoint=http://localhost:8984/rest ^
     -p username=admin ^
     -p password=admin ^
     -p auth-method=Basic ^
     -o result=tutorial/xquery-tutorial-result.html ^
     src\harnesses\basex\basex-server-xquery-harness.xproc
Clone this wiki locally