Skip to content

Saxon CLI

Christian Lück edited this page Sep 19, 2025 · 4 revisions

Saxon CLI

You just need an XSLT 3.0 processor to use xtriples-micro for extracting triples from XML. You can use the Home Edition of Saxon on the command line.

To keep things simple, we first export an environment variable that stores our command:

export XSLT=java -jar saxon-he-10.9.jar

If you have the Tooling environment installed and setup, say export XSLT=$(realpath target/bin/xslt.sh) for this exercise.

For this exercise, the following input to your shell should give you this:

$ $XSLT -?
Saxon-HE 10.9J from Saxonica
Usage: see http://www.saxonica.com/documentation/index.html#!using-xsl/commandline
Format: net.sf.saxon.Transform options params
Options available: -? -a -catalog -config -cr -diag -dtd -ea -expand -explain -export -ext -im -init -it -jit -l -lib -license -m -nogo -now -ns -o -opt -or -outval -p -quit -r -relocate -repeat -s -sa -scmin -strip -t -T -target -TB -threads -TJ -Tlevel -Tout -TP -traceout -tree -u -val -versionmsg -warnings -x -xi -xmlversion -xsd -xsdversion -xsiloc -xsl -y --?
Use -XYZ:? for details of option XYZ
Params: 
  param=value           Set stylesheet string parameter
  +param=filename       Set stylesheet document parameter
  ?param=expression     Set stylesheet parameter using XPath
  !param=value          Set serialization parameter

You should also provide a variable with a path to your xtriples-micro installation:

export XTRIPLES=$(realpath .)

3 Ways to Use xtriples-micro

There are 3 different ways to use xtriples-micro:

1. XTriples Configuration as Source

The straight forward usage is applying the xtriples-micro XSLT on an XTriples configuration file as source.

$XSLT -xsl:$XTRIPLES/xsl/extract-collection.xsl -s:CONFIGURATION.xml

Which XML documents are extracted is determined by the <collection> elements in the configuration file. This usage is compatible with the reference implementation. We use it in CI/CD Pipelines.

2. XML as Source; XTriples configuration by Parameter

xsl/extract.xsl extracts from an XML document given as source by applying a configuration passed in via the stylesheet parameter config-uri.

$XSLT -xsl:$XTRIPLES/xsl/extract.xsl -s:DOCUMENT.xml config-uri=CONFIGURATION.xml

This is the only transformation that makes sense deploying on a micro service.

3. XTriples configuration as Source; XML as parameter

xsl/extract-doc-param.xsl takes a configuration as source document and applies it to an XML document referenced by the source-uri stylesheet parameter.

$XSLT -xsl:$XTRIPLES/xsl/extract-param-doc.xsl -s:CONFIGURATION.xml source-uri=DOCUMENT.xml

Clone this wiki locally