Illegal character in opaque part at index 15: xslt:transform("small.xml", "transform.xsl")
Depending on your operating system, you might need to swap the parentheses:
basex -o output.xml "xslt:transform('small.xml', 'transform.xsl')"
Hope this helps, Christian
On 22/07/25, Christian Grün (cg@basex.org) wrote:
Hi Roy, thanks all,
As indicated by Martin, …
file:write($output, xslt:transform($input, $stylesheet))
…works with BaseX 10.5. For the latest proposed syntax, you will need to switch to a newer version.
You can also use supply the XQuery code on command line and specify an output target:
basex -o output.xml 'xslt:transform("small.xml", "transform.xsl")'
…or, as suggested:
__ wrapper.xqy: declare variable $input as xs:string external; declare variable $stylesheet as xs:string external; xslt:transform($input, $stylesheet)
__ command-line: basex -o output.xml -b input=small.xml -b stylesheet=transform.xsl wrapper.xqy
Best, Christian
Von: Martin Honnen via BaseX-Talk basex-talk@mailman.uni-konstanz.de Gesendet: Dienstag, 22. Juli 2025 18:23 An: basex-talk@mailman.uni-konstanz.de basex-talk@mailman.uni-konstanz.de Betreff: [basex-talk] Re: command line xsl transformation
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))