User
User

Reputation: 24739

How to execute xq files on xml files?

I have .xq files that I want to run again some XML data sets. Is there a tool that can be used to run Xquery files again XML data in command line on OSX?

I've already read this: How to execute XPath one-liners from shell?

Upvotes: 2

Views: 3272

Answers (2)

Florent Georges
Florent Georges

Reputation: 2327

If you like packaged bundles, you might be interested by the EXPath repository manager. It comes with Saxon and Calabash (you can pick which to install), as well as scripts to run them with proper classpath, class, etc. It comes with a graphical installer.

To install it:

  • go to http://expath.org/files/pkg
  • download the latest expath-repo-installer-*.jar
  • execute it (e.g. java -jar ~/Downloads/expath-repo-installer-*.jar)
  • (optional) add the dir bin/ where it has been installed to your PATH

On the shell, just invoke saxon --help (or ~/expath/pkg/bin/saxon --help or any ther place you installed it if you did not put it in the PATH), and follow the instructions. All options like --xxx at the beginning of the command line are consumed by the script itself. All the rest is passed as is to Saxon.

For instance to execute a query from the command line, with a specific document as the context item:

saxon --xq -s:data.xml -q:query.xq

Upvotes: 0

Charles Duffy
Charles Duffy

Reputation: 295650

For BaseX, to evaluate file.xq against the contents in in.xml and write the result to out.xml:

basex -iin.xml -oout.xml file.xq

Much more documentation is available on the wiki.


For Saxon, to perform the same operation:

java net.sf.saxon.Query -s:in.xml -q:file.xq -o:out.xml

Documentation likewise available.

Upvotes: 3

Related Questions