Running with XProc - xspec/xspec GitHub Wiki
Contents
Introduction
XProc is a language to define XML pipelines. It is a W3C recommendation and there are several XProc implementations. In order to run XSpec tests with XProc, you must install an XProc implementation. Choose between XProc 3.x (recommended) and XProc 1.
Run an XSpec test with XProc version 3
XSpec v3.3 has pipelines for running tests with an XProc version 3 processor. These instructions use XML Calabash 3 with the XProc harness (for XSLT, XQuery, or Schematron). XML Calabash is configurable to run XQuery code with Saxon (default), BaseX, eXist-db, or Elemental.
Setup
-
From the XML Calabash 3 release page, find the latest release, download its
xmlcalabash-3.y.z.zipfile for that 3.y.z release, and unzip it to a local path (e.g.,/tmp/xmlcalabash3for Linux/macOS orC:\xmlcalabash3for Windows). Make sure you download the zip file because libraries are required (that is, using only the jar file won't work). XML Calabash version 3.0.34 is used here. -
(Optional) If you want to run an XSpec test for XQuery using BaseX as the XQuery processor, or if you want to run an XSpec test for Schematron with XQS as the Schematron implementation, then also download
basex-3.y.z.zipand unzip it. From theextradirectory of this archive, copy the individual*.jarfiles directly into the correspondingextrasubdirectory of your installation from step 1. -
Make sure Java 11 or later (17 or later, if using BaseX) is installed, e.g.:
java -version -
Make sure XSpec v3.3 or later is available in a local path (e.g.,
/tmp/xspecfor Linux/macOS orC:\xspecfor Windows).
Note about Saxon version: Saxon is one of the dependencies that XML Calabash 3 includes in its ZIP-file, and the procedures here use the bundled Saxon instead of one you might have installed separately on your system.
Now, jump to one of these subsections, depending on the kind of test you want to run:
- XSpec test for XSLT with XProc 3
- XSpec test for XQuery with XProc 3
- XSpec test for XQuery with XProc 3 and BaseX XQuery processor
- XSpec test for Schematron with XProc 3 and XSLT-based implementation of Schematron
- XSpec test for Schematron with XProc 3 and XQS implementation of Schematron
XSpec test for XSLT with XProc 3
After completing the setup, do the following:
-
Navigate to your XSpec directory (not essential but simplifies the relative paths in the sample command below).
-
Run an XSpec test for XSLT as follows:
For Linux/macOS:
java -jar /tmp/xmlcalabash3/xmlcalabash-app-3.0.34.jar \ --input:source=tutorial/escape-for-regex.xspec \ --output:result=tutorial/escape-for-regex-result.html \ src/xproc3/run-xslt.xpl \ xspec-home=file:/tmp/xspec/For Windows:
java -jar C:\xmlcalabash3\xmlcalabash-app-3.0.34.jar ^ --input:source=tutorial/escape-for-regex.xspec ^ --output:result=tutorial/escape-for-regex-result.html ^ src/xproc3/run-xslt.xpl ^ xspec-home=file:///C:/xspec/where:
-jaris the XML Calabash jar file--input:sourceis the input port with the XSpec test to be executed--output:resultis the output port where the HTML report will be storedrun-xslt.xplis the XProc 3 harness for XSLTxspec-homeis the absolute URI of the XSpec installation
Output:
XSpec v3.3.1 Checking for deprecated Saxon versions: Passed Testing with SAXON HE 12.9 No escaping Must not be escaped at all Test simple patterns ..When encountering parentheses escape them. ..When encountering a whitespace character class escape the backslash result should have one more character than source When processing a list of phrases All phrase elements should remain Strings should be escaped and status attributes should be added FAILED passed: 5 / pending: 0 / failed: 1 / total: 6The HTML report file is created in the location specified by
--output:result.
XSpec test for XQuery with XProc 3
After completing the setup, do the following:
-
Navigate to your XSpec directory (not essential but simplifies the relative paths in the sample command below).
-
Run an XSpec test for XQuery as follows:
For Linux/macOS:
java -jar /tmp/xmlcalabash3/xmlcalabash-app-3.0.34.jar \ --input:source=tutorial/xquery-tutorial.xspec \ --output:result=tutorial/xquery-tutorial-result.html \ src/xproc3/run-xquery.xpl \ xspec-home=file:/tmp/xspec/For Windows:
java -jar C:\xmlcalabash3\xmlcalabash-app-3.0.34.jar ^ --input:source=tutorial/xquery-tutorial.xspec ^ --output:result=tutorial/xquery-tutorial-result.html ^ src/xproc3/run-xquery.xpl ^ xspec-home=file:///C:/xspec/where:
-jaris the XML Calabash jar file--input:sourceis the input port with the XSpec test to be executed--output:resultis the output port where the HTML report will be storedrun-xquery.xplis the XProc 3 harness for XQueryxspec-homeis the absolute URI of the XSpec installation
Output:
XSpec v3.3.1 Checking for deprecated Saxon versions: Passed passed: 1 / pending: 0 / failed: 0 / total: 1The HTML report file is created in the location specified by
--output:result.
XSpec test for XQuery with XProc 3 and BaseX XQuery processor
To run the same test with BaseX instead of Saxon as the XQuery processor, first complete the setup with the optional basex-3.y.z.zip download. Then, follow the steps in XSpec test for XQuery with XProc 3 but use this command instead:
For Linux/macOS:
java -cp /tmp/xmlcalabash3/xmlcalabash-app-3.0.34.jar;/tmp/xmlcalabash3/extra/*" \
com.xmlcalabash.app.Main --configuration:src/xproc3/schematron-xqs/xmlcalabash3-config.xml \
--input:source=tutorial/xquery-tutorial.xspec \
--output:result=tutorial/xquery-tutorial-result.html \
src/xproc3/run-xquery.xpl \
xspec-home=file:/tmp/xspec/
For Windows:
java -cp "C:\xmlcalabash3\xmlcalabash-app-3.0.34.jar;C:\xmlcalabash3\extra\*" ^
com.xmlcalabash.app.Main --configuration:src/xproc3/schematron-xqs/xmlcalabash3-config.xml ^
--input:source=tutorial/xquery-tutorial.xspec ^
--output:result=tutorial/xquery-tutorial-result.html ^
src/xproc3/run-xquery.xpl ^
xspec-home=file:///C:/xspec/
XSpec test for Schematron with XProc 3 and XSLT-based implementation of Schematron
Not supported yet (#2160).
XSpec test for Schematron with XProc 3 and XQS implementation of Schematron
If your Schematron schema uses an XQuery-based queryBinding, the schema should be processed with an XQuery-based implementation of Schematron like XQS, instead of an XSLT-based implementation of Schematron like SchXslt. To run an XSpec test for such a schema, first complete the setup with the optional basex-3.y.z.zip download. Then, do the following:
-
Navigate to your XSpec directory (not essential but simplifies the relative paths in the sample command below).
-
Run an XSpec test for Schematron with XQS as follows:
For Linux/macOS:
java -cp "/tmp/xmlcalabash3/xmlcalabash-app-3.0.34.jar:/tmp/xmlcalabash3/extra/*" \ com.xmlcalabash.app.Main \ --config:src/xproc3/schematron-xqs/xmlcalabash3-config.xml \ --input:source=test/xqs/schematron-for-xqs-expect.xspec \ --output:result=test/xqs/schematron-for-xqs-expect-result.html \ src/xproc3/schematron-xqs/run-schematron-xqs.xpl \ xspec-home=file:/tmp/xspec/For Windows:
java -cp "C:\xmlcalabash3\xmlcalabash-app-3.0.34.jar;C:\xmlcalabash3\extra\*" ^ com.xmlcalabash.app.Main ^ --config:src/xproc3/schematron-xqs/xmlcalabash3-config.xml ^ --input:source=test/xqs/schematron-for-xqs-expect.xspec ^ --output:result=test/xqs/schematron-for-xqs-expect-result.html ^ src/xproc3/schematron-xqs/run-schematron-xqs.xpl ^ xspec-home=file:///C:/xspec/where:
-cpis the classpath for XML Calabashcom.xmlcalabash.app.Mainis the entry point to XML Calabash--configpoints to a configuration file that specifies BaseX as the XQuery processor--input:sourceis the input port with the XSpec test to be executed--output:resultis the output port where the HTML report will be storedrun-schematron-xqs.xplis the XProc 3 harness for Schematron via XQSxspec-homeis the absolute URI of the XSpec installation
Output:
XSpec v3.3.1 Checking for deprecated Saxon versions: Passed passed: 38 / pending: 0 / failed: 0 / total: 38The HTML report file is created in the location specified by
--output:result.
Run an XSpec test with XProc version 1
As an example, this description uses XML Calabash 1 with the Saxon XProc harness (for XSLT or for XQuery). Harnesses for BaseX are also available.
-
Download the zip file of XML Calabash 1 latest release and unzip it to a local path (e.g.,
/tmp/xmlcalabashfor Linux/macOS orC:\xmlcalabashfor Windows). Make sure you download the zip file because libraries are required (that is, using only the jar file won't work). XML Calabash version 1.1.27-99 is used here. -
Make sure Java is installed, e.g.:
java -version -
Make sure XSpec is available in a local path (e.g.,
/tmp/xspecfor Linux/macOS orC:\xspecfor Windows). -
Navigate to your XSpec directory.
-
Run an XSpec test for XSLT as follows:
For Linux/macOS:
java -jar /tmp/xmlcalabash/xmlcalabash-1.2.5-99.jar \ -i source=tutorial/escape-for-regex.xspec \ -o result=tutorial/escape-for-regex-result.html \ -p xspec-home=file:/tmp/xspec/ \ src/harnesses/saxon/saxon-xslt-harness.xprocFor Windows:
java -jar C:\xmlcalabash\xmlcalabash-1.2.5-99.jar ^ -i source=tutorial/escape-for-regex.xspec ^ -o result=tutorial/escape-for-regex-result.html ^ -p xspec-home=file:///C:/xspec/ ^ src\harnesses\saxon\saxon-xslt-harness.xprocwhere:
-jaris the XML Calabash jar file-i sourceis the input port with the XSpec test to be executed-o resultis the output port where the HTML report will be stored-p xspec-homeis the absolute URI of the XSpec installationsaxon-xslt-harness.xprocis the Saxon XProc harness for XSLT
The output result from the command line may look like this:
INFO : src/harnesses/saxon/saxon-xslt-harness.xproc:41:46:Testing with SAXON HE 9.9.1.2 INFO : src/harnesses/saxon/saxon-xslt-harness.xproc:41:46:No escaping INFO : src/harnesses/saxon/saxon-xslt-harness.xproc:41:46:Must not be escaped at all INFO : src/harnesses/saxon/saxon-xslt-harness.xproc:41:46:Test simple patterns INFO : src/harnesses/saxon/saxon-xslt-harness.xproc:41:46:..When encountering parentheses INFO : src/harnesses/saxon/saxon-xslt-harness.xproc:41:46:escape them. INFO : src/harnesses/saxon/saxon-xslt-harness.xproc:41:46:..When encountering a whitespace character class INFO : src/harnesses/saxon/saxon-xslt-harness.xproc:41:46:escape the backslash INFO : src/harnesses/saxon/saxon-xslt-harness.xproc:41:46:result should have one more character than source INFO : src/harnesses/saxon/saxon-xslt-harness.xproc:41:46:When processing a list of phrases INFO : src/harnesses/saxon/saxon-xslt-harness.xproc:41:46:All phrase elements should remain INFO : src/harnesses/saxon/saxon-xslt-harness.xproc:41:46:Strings should be escaped and status attributes should be added INFO : src/harnesses/saxon/saxon-xslt-harness.xproc:41:46: FAILED INFO : src/harnesses/harness-lib.xpl:267:45:passed: 5 / pending: 0 / failed: 1 / total: 6The HTML report file is created in the location specified by
-o result=. -
Run an XSpec test for XQuery as follows:
Make sure to use
saxon-xquery-harness.xproc.For Linux/macOS:
java -jar /tmp/xmlcalabash/xmlcalabash-1.2.5-99.jar \ -i source=tutorial/xquery-tutorial.xspec \ -o result=tutorial/xquery-tutorial-result.html \ -p xspec-home=file:/tmp/xspec/ \ src/harnesses/saxon/saxon-xquery-harness.xprocFor Windows:
java -jar C:\xmlcalabash\xmlcalabash-1.2.5-99.jar ^ -i source=tutorial/xquery-tutorial.xspec ^ -o result=tutorial/xquery-tutorial-result.html ^ -p xspec-home=file:///C:/xspec/ ^ src\harnesses\saxon\saxon-xquery-harness.xprocOutput:
INFO : src/harnesses/harness-lib.xpl:267:45:passed: 1 / pending: 0 / failed: 0 / total: 1