Running with BaseX - xspec/xspec GitHub Wiki
Introduction
BaseX is an open source XML database engine and XPath/XQuery 4.0 processor. BaseX can be run as standalone, web application, database server, or GUI application. Running XSpec tests with BaseX requires an XProc implementation.
XProc 3
The XSpec distribution has an XProc 3 harness for running tests for XQuery. Whether the XQuery code ultimately runs with BaseX or Saxon is a configuration choice in the underlying XProc 3 processor. For instructions that use XML Calabash 3, see XSpec test for XQuery with XProc 3 and BaseX XQuery processor.
XProc 1
The XSpec distribution has dedicated XProc 1 harnesses for BaseX, described next.
Dependencies
XML Calabash 1 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
-
Download the ZIP package of BaseX and extract it to a local directory (e.g.
~/xml/basexfor Linux/macOS orC:\basexfor Windows). -
Make sure a required version of Java Runtime Environment is installed, e.g.:
java -version -
Make sure XSpec is available in a local path (e.g.
~/xml/xspecfor Linux/macOS orC:\xspecfor Windows). -
Navigate to your XSpec directory.
-
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.xprocFor 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.xprocwhere:
-jaris the XML Calabash jar file-i sourceis the input port with the XSpec test for XQuery to be executed-o resultis the output port where the HTML report will be stored-p xspec-homeis the absolute URI of the XSpec installation-p basex-jaris the jar file of BaseXbasex-standalone-xquery-harness.xprocis 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-jarparameter, provideendpoint,username,passwordandauth-method - Instead of the
basex-standalone-xquery-harness.xprocharness, usebasex-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