1

How is this sample xquery executed from the CLI?

xquery version "1.0";
let $message := 'Hello World!'
return
<results>
   <message>{$message}</message>
</results>

xquery

Inspired from zx485's answer:

Check the separate libxslt page

XSL Transformations, is a language for transforming XML documents into other XML documents (or HTML/textual output).

A separate library called libxslt is available implementing XSLT-1.0 for libxml2. This module "libxslt" too can be found in the Gnome SVN base.

You can check the progresses on the libxslt Changelog.

Daniel Veillard

http://xmlsoft.org/XSLT.html

Thufir
  • 8,216
  • 28
  • 125
  • 273

1 Answers1

2

You can do it with Saxon like in this extensive tutorial.

To summarize it, copy the XQuery code to a file (here named test.xq) and then execute it with (the current version of) Saxon:

java -cp saxon9he.jar net.sf.saxon.Query test.xq

The output in your sample case would be

<results>
    <message>Hello World!</message>
</results>

as desired.

zx485
  • 28,498
  • 28
  • 50
  • 59
  • as a practical matter, do many people run .xq from the CLI? chain them together? or, is that madness? – Thufir Dec 31 '18 at 20:41
  • 1
    Honestly, I don't know. But to me, it doesn't seem that unusual. I would just weight its use cases against applying an XSLT-3.0 file. What's better? (Probably) you decide it for yourself. – zx485 Dec 31 '18 at 20:49
  • 1
    If you're running multiple queries, then you don't want the overhead of loading the Java VM for each one; if you're running a pipeline then you probably want something like XProc or Ant or xmlsh to link things together. But plenty of people want convenience above performance, and for that, running from a shell is just fine. – Michael Kay Jan 01 '19 at 00:39