Note: The homebrew recipe for installing Saxon shown here was created and is maintained by the community. It is not Saxon's official method of installation. The official method can be found at http://www.saxonica.com/documentation/index.html#!about/gettingstarted/gettingstartedjava and http://www.saxonica.com/documentation/index.html#!using-xquery/commandline.
$ brew install saxon
$ brew info saxon
saxon: stable 9.7.0.4
XSLT and XQuery processor
http://saxon.sourceforge.net
/usr/local/Cellar/saxon/9.7.0.4 (14 files, 4.8M) *
Built from source on 2016-04-14 at 09:40:59
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/saxon.rb
echo 'xquery version "3.1"; <message>hello world</message>' > hello-world.xq
$ java -cp /usr/local/Cellar/saxon/9.7.0.4/libexec/saxon9he.jar net.sf.saxon.Query -qversion:3.1 hello-world.xq
<?xml version="1.0" encoding="UTF-8"?><message>hello world</message>
$ brew --prefix saxon
/usr/local/opt/saxon
$ alias saxonxq='java -cp "`brew --prefix saxon`/libexec/saxon9he.jar" net.sf.saxon.Query -qversion:3.1'
$ saxonxq
No query file name
Saxon-HE 9.7.0.4J from Saxonica
Usage: see http://www.saxonica.com/html/documentation/using-xquery/commandline.html
Format: net.sf.saxon.Query options params
Options available: -? -backup -catalog -config -cr -dtd -expand -explain -ext -init -l -mr -now -o -opt -outval -p -pipe -projection -q -qs -quit -qversion -r -repeat -s -sa -scmin -stream -strip -t -T -TJ -TP -traceout -tree -u -update -val -wrap -x -xi -xmlversion -xsd -xsdversion -xsiloc
Use -XYZ:? for details of option XYZ
Params:
param=value Set query string parameter
+param=filename Set query document parameter
?param=expression Set query parameter using XPath
!param=value Set serialization parameter
$ saxonxq hello-world.xq
<?xml version="1.0" encoding="UTF-8"?><message>hello world</message>
If you think you'll use the alias again, save it into your ~/.bash_profile
.
Since Saxon 9.8 there is no option '-qversion' anymore: cf. https://www.saxonica.com/documentation9.8/index.html#!using-xquery