I guess I could make some XSL stylesheet, then use it as a template with parameter option to evaluate XPath expression with Saxon XSLT processor on command line, like:
You can run Saxon (XQuery) from the command line. You can do this by pointing to a file that has the XPath/XQuery using -q or you can pass the query string directly using -qs.
Here's an example of using -qs to process a simple XPath:
input.xml
Saxon command line (I used Saxon9-HE to test with)
java -cp "saxon9he.jar" net.sf.saxon.Query -s:"input.xml" -qs:"/a/b[@id='x']" -o:"results.xml"
results.xml
Note: I could've made my output well-formed by changing the -qs to something like this: -qs:".
For more command line options, look here: http://www.saxonica.com/html/documentation/using-xquery/commandline.html