On 22/07/2025 18:03, Rory Campbell-Lange wrote:
Hi Yitzhak
That is an incredibly helpful Xquery example.
Unfortunately I'm unable to get it to run on my Linux machine.
While this (Saxon-HE) works ok:
saxon -s:small.xml -xsl:transform.xsl -o:result.html
basex returns a stacktrace (shown at the bottom of my email) when I run the basex query below, modelled on yours but using quoting which I think is correct for linux.
basex -b '$input=small.xml' -b '$stylesheet=transform.xsl' wrapper.xqy
This fails with a
java.lang.ArrayIndexOutOfBoundsException: Index -1 out of bounds for length 8
error, although I don't believe I'm using any range/iterator expressions.
First of all, to use XSLT 2 or 3 with BaseX, you need to add Saxon HE Java library (current version is 12.8, but I think 11.7 or even 10.9 would work, too) to the BaseX lib folder, plus its dependencies like XML resolver.
Then note that the current version of BaseX is 12, so with 10.5 you are using an outdated version (might be because you went with a Linux package).
I am not quite sure what causes the error you get but I think Yitzhak took advantage of recent updates to XQuery, like the "->" operator, I am not sure that was supported in 10.5. Wait for Christian to tell.
Perhaps instead of
xslt:transform($input, $stylesheet) -> file:write($output, .)
you could try
file:write($output, xslt:transform($input, $stylesheet))