Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

simple command line xquery

I'm trying to find a simple cli command to do xquery from linux shell. What I'd like is to avoid external dependencies that I need to install (using fedora 18).

What I already found is saxon and xqilla that I can install through yum. I can use them if nothing else but they are not in the base system. What I hoped to find is something like the java internal class for doing xslt processing (com.sun.org.apache.xalan.internal.xsltc.cmdline.Transform).

One other idea I have is use XSLT to transform the document to the desired xquery result but one-liners would not be possible.

example of what I can do with xqilla (but searching for another utility):

$ xqilla -i TEST-com.ecample.testcase.MyTestCase.xml <(echo '/testsuite/@failures + /testsuite/@errors')

UPDATE: not exactly the question I had but I settled on perl XML::Twig being installed by default and giving me the flexibility to implement complicated logic with perl. That also led to a nice speed boost because there is no need to fork a process for each XML file.

like image 998
akostadinov Avatar asked Aug 22 '26 18:08

akostadinov


1 Answers

For XQuery 1 there is my Xidel. Works like this:

 $ xidel TEST-com.ecample.testcase.MyTestCase.xml -e 'xquery version "1.0"; /testsuite/@failures + /testsuite/@errors'

Completely dependency free, but not in the base system, not java, and it has no support for XML schemas...

like image 59
BeniBela Avatar answered Aug 25 '26 07:08

BeniBela