Hi -- beginner here.
I've installed basex via apt on Debian.
ii basex 10.5-1 all XML database and XPath/XQuery processor
I've successfully made and interrogated a database and made a few basic xquery commands from the command line.
I'm hoping to use basex for xsl transformations from the command line so that I can work rapidly on iterating towards the transformation I'm trying to achieve. Specifically, I'm aiming to transform an XML document using an XSL document to produce an HTML document. I've tried the following, plus other variants:
basex -W -i input.xml -o out.html transform.xsl
However the resulting file at out.html is simply the transform.xsl file.
I'd be grateful for advice.
Many thanks, Rory
Hi Rory,
BaseX is an _XQuery_ processor. It can call XSL processors usind the xslt module. But is _not_ an XSL processor itself.
Would it be an option for you to use an actual XSL processor for the task? * XSL 2.0+ Saxon (https://www.saxonica.com/download/download_page.xml). Several language bindings are available nowadays. * XSL 1.0 xsltproc (https://packages.debian.org/bookworm/xsltproc)
I can assure you this will be easier than getting basex to call an XSL processor for you and present you the results.
If you really want to use BaseX for that task you need to write a minimal XQuery snippet that calls xslt:transform or xslt:transfrom-text.
Am 22.07.2025 um 12:44 schrieb Rory Campbell-Lange:
Hi -- beginner here.
I've installed basex via apt on Debian.
ii basex 10.5-1 all XML database and XPath/XQuery processor
I've successfully made and interrogated a database and made a few basic xquery commands from the command line.
I'm hoping to use basex for xsl transformations from the command line so that I can work rapidly on iterating towards the transformation I'm trying to achieve. Specifically, I'm aiming to transform an XML document using an XSL document to produce an HTML document. I've tried the following, plus other variants:
basex -W -i input.xml -o out.html transform.xsl
However the resulting file at out.html is simply the transform.xsl file.
I'd be grateful for advice.
Many thanks, Rory
Best regards
Greetings,
In past projects I have built XSLT pipelines using XQuery as the 'driver' language - it works, and it works well in BaseX, while requiring additional support from Saxon for the XSLT part. It can work with scripts, behind a web service (RestXQ) etc.
If that specifically is your interest, it remains a BaseX question how best to do it. (My project was ten years ago now!)
If the question is more about how to run XSLT from the command line, the options mentioned are available - but also, we should not overlook, in this context, XProc 3.
An XProc 3.0/3.1 engine (such as XML Calabash or Morgana XProc IIIse) can execute and orchestrate processing pipelines applying either or both XQuery and XSLT to XML, and much more.
Regards, Wendell
XML Calabash: https://www.xmlcalabash.com/ Morgana XProc IIIse: https://www.xml-project.com/morganaxproc-iiise.html
On Tue, Jul 22, 2025 at 6:58 AM Omar Siam Omar.Siam@oeaw.ac.at wrote:
Hi Rory,
BaseX is an _XQuery_ processor. It can call XSL processors usind the xslt module. But is _not_ an XSL processor itself.
Would it be an option for you to use an actual XSL processor for the task?
- XSL 2.0+ Saxon (https://www.saxonica.com/download/download_page.xml).
Several language bindings are available nowadays.
- XSL 1.0 xsltproc (https://packages.debian.org/bookworm/xsltproc)
I can assure you this will be easier than getting basex to call an XSL processor for you and present you the results.
If you really want to use BaseX for that task you need to write a minimal XQuery snippet that calls xslt:transform or xslt:transfrom-text.
Am 22.07.2025 um 12:44 schrieb Rory Campbell-Lange:
Hi -- beginner here.
I've installed basex via apt on Debian.
ii basex 10.5-1 all XML database and XPath/XQuery processor
I've successfully made and interrogated a database and made a few basic xquery commands from the command line.
I'm hoping to use basex for xsl transformations from the command line so that I can work rapidly on iterating towards the transformation I'm trying to achieve. Specifically, I'm aiming to transform an XML document using an XSL document to produce an HTML document. I've tried the following, plus other variants:
basex -W -i input.xml -o out.html transform.xsl
However the resulting file at out.html is simply the transform.xsl file.
I'd be grateful for advice.
Many thanks, Rory
Best regards
-- Mag. Ing. Omar Siam Austrian Center for Digital Humanities and Cultural Heritage Österreichische Akademie der Wissenschaften | Austrian Academy of Sciences Stellvertretende Behindertenvertrauensperson | Deputy representative for disabled persons Bäckerstraße 13, 1010 Wien, Österreich | Vienna, Austria T: +43 1 51581-7295omar.siam@oeaw.ac.at | www.oeaw.ac.at/acdh
Thank you for the further pointers, Wendell.
I'm coming from experience with REST servers backed by procedural SQL, so the sort of architecture you mention is not foreign to me in abstract, but I haven't looked at XML processing for quite some time (or, indeed, worked with any java tools).
The context of my enquiries are related to processing Akoma Ntoso judicial documents.
I haven't worked with XProc at all so I'll add it to my research list. Thank you very much for the pointers.
Regards, Rory
On 22/07/25, Wendell Piez (wapiez@wendellpiez.com) wrote:
Greetings,
In past projects I have built XSLT pipelines using XQuery as the 'driver' language - it works, and it works well in BaseX, while requiring additional support from Saxon for the XSLT part. It can work with scripts, behind a web service (RestXQ) etc.
If that specifically is your interest, it remains a BaseX question how best to do it. (My project was ten years ago now!)
If the question is more about how to run XSLT from the command line, the options mentioned are available - but also, we should not overlook, in this context, XProc 3.
An XProc 3.0/3.1 engine (such as XML Calabash or Morgana XProc IIIse) can execute and orchestrate processing pipelines applying either or both XQuery and XSLT to XML, and much more.
Regards, Wendell
XML Calabash: https://www.xmlcalabash.com/ Morgana XProc IIIse: https://www.xml-project.com/morganaxproc-iiise.html
On Tue, Jul 22, 2025 at 6:58 AM Omar Siam Omar.Siam@oeaw.ac.at wrote:
Hi Rory,
BaseX is an _XQuery_ processor. It can call XSL processors usind the xslt module. But is _not_ an XSL processor itself.
Would it be an option for you to use an actual XSL processor for the task?
- XSL 2.0+ Saxon (https://www.saxonica.com/download/download_page.xml).
Several language bindings are available nowadays.
- XSL 1.0 xsltproc (https://packages.debian.org/bookworm/xsltproc)
I can assure you this will be easier than getting basex to call an XSL processor for you and present you the results.
If you really want to use BaseX for that task you need to write a minimal XQuery snippet that calls xslt:transform or xslt:transfrom-text.
Am 22.07.2025 um 12:44 schrieb Rory Campbell-Lange:
Hi -- beginner here.
I've installed basex via apt on Debian.
ii basex 10.5-1 all XML database and XPath/XQuery processor
I've successfully made and interrogated a database and made a few basic xquery commands from the command line.
I'm hoping to use basex for xsl transformations from the command line so that I can work rapidly on iterating towards the transformation I'm trying to achieve. Specifically, I'm aiming to transform an XML document using an XSL document to produce an HTML document. I've tried the following, plus other variants:
basex -W -i input.xml -o out.html transform.xsl
However the resulting file at out.html is simply the transform.xsl file.
I'd be grateful for advice.
Many thanks, Rory
Best regards
-- Mag. Ing. Omar Siam Austrian Center for Digital Humanities and Cultural Heritage Österreichische Akademie der Wissenschaften | Austrian Academy of Sciences Stellvertretende Behindertenvertrauensperson | Deputy representative for disabled persons Bäckerstraße 13, 1010 Wien, Österreich | Vienna, Austria T: +43 1 51581-7295omar.siam@oeaw.ac.at | www.oeaw.ac.at/acdh
-- ...Wendell Piez... ...wendell -at- nist -dot- gov... ...wendellpiez.com... ...pellucidliterature.org... ...pausepress.org... ...github.com/wendellpiez... ...gitlab.coko.foundation/wendell...
Hi Omar
My apologies for assuming basex had intrinsic xslt capabilities (I've been working with MarkLogic and kind of assuemed this might be all part of the same package, also since XSLT is mentiond on the BaseX XQuery page at https://basex.org/basex/xquery/).
I'll have a good look at saxon and xsltprox. Thanks very much for the pointers. I'll fall back on a BaseX wrapper snippet as you suggest if needed.
Thanks again, Rory
On 22/07/25, Omar Siam (Omar.Siam@oeaw.ac.at) wrote:
Hi Rory,
BaseX is an _XQuery_ processor. It can call XSL processors usind the xslt module. But is _not_ an XSL processor itself.
Would it be an option for you to use an actual XSL processor for the task?
- XSL 2.0+ Saxon (https://www.saxonica.com/download/download_page.xml).
Several language bindings are available nowadays.
- XSL 1.0 xsltproc (https://packages.debian.org/bookworm/xsltproc)
I can assure you this will be easier than getting basex to call an XSL processor for you and present you the results.
If you really want to use BaseX for that task you need to write a minimal XQuery snippet that calls xslt:transform or xslt:transfrom-text.
Am 22.07.2025 um 12:44 schrieb Rory Campbell-Lange:
Hi -- beginner here.
I've installed basex via apt on Debian.
ii basex 10.5-1 all XML database and XPath/XQuery processor
I've successfully made and interrogated a database and made a few basic xquery commands from the command line.
I'm hoping to use basex for xsl transformations from the command line so that I can work rapidly on iterating towards the transformation I'm trying to achieve. Specifically, I'm aiming to transform an XML document using an XSL document to produce an HTML document. I've tried the following, plus other variants:
basex -W -i input.xml -o out.html transform.xsl
However the resulting file at out.html is simply the transform.xsl file.
I'd be grateful for advice.
Many thanks, Rory
Best regards
-- Mag. Ing. Omar Siam Austrian Center for Digital Humanities and Cultural Heritage Österreichische Akademie der Wissenschaften | Austrian Academy of Sciences Stellvertretende Behindertenvertrauensperson | Deputy representative for disabled persons Bäckerstraße 13, 1010 Wien, Österreich | Vienna, Austria T: +43 1 51581-7295 omar.siam@oeaw.ac.at |www.oeaw.ac.at/acdh
Hi Rory,
It is very easy to run XSLT transformations directly in BaseX.
BaseX has a built-in XSLT module for that. By default it supports XSLT 1.0 standard. If needed you can extend it up to XSLT 4.0 via Saxon.
First, you need to prepare a tiny XQuery file for that.\ It accepts two parameters: - $input, to specify input XML file - $stylesheet, to specify XSLT file
In my example the result output file gets calculated name with a specific suffix: "_output.xml" But it could be a 3rd parameter too.
xquery_xslt.qy ============================== declare variable $input as xs:string external; declare variable $stylesheet as xs:string external;
let $output := substring-before($input, ".") || "_output.xml" return xslt:transform($input, $stylesheet) -> file:write($output, .)
Second, launch XSLT transformation at the command prompt: basex.bat -b $input="path/to/input.xml" -b $stylesheet="path/to/transform.xslt" "path/to/xquery_xslt.qy"
Regards, Yitzhak Khabinsky
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.
I'm using the following files:
transform:xsl: ```xsl <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:akn="http://docs.oasis-open.org/legaldocml/ns/akn/3.0" exclude-result-prefixes="akn">
<xsl:template match="/akn:akomaNtoso"> <main id="main-content"> <xsl:apply-templates select="akn:judgment"/> </main> </xsl:template>
</xsl:stylesheet> ```
small.xml: ```xml <akomaNtoso xmlns="http://docs.oasis-open.org/legaldocml/ns/akn/3.0"> <judgment name="judgment"> <meta> </meta> <header> <p>A Header Paragraph</p> </header> <judgmentBody> <paragraph eId="para_1"> <num>1.</num> <content> <p>This is the first paragraph of the judgment.</p> </content> </paragraph> </judgmentBody> </judgment> </akomaNtoso> ```
wrapper.xqy: ``` declare variable $input as xs:string external; declare variable $stylesheet as xs:string external;
let $output := substring-before($input, ".") || "_output.xml" return xslt:transform($input, $stylesheet) -> file:write($output, .) ```
stack trace: ``` $ basex -b '$input=small.xml' -b '$stylesheet=transform.xsl' wrapper.xqy [warning] /usr/bin/basex: Unable to locate /usr/share/java/tagsoup.jar in /usr/share/java [warning] /usr/bin/basex: Unable to locate /usr/share/java/jing.jar in /usr/share/java Improper use? Potential bug? Your feedback is welcome: Contact: basex-talk@mailman.uni-konstanz.de Version: BaseX 10.5 Java: Debian, 21.0.6 OS: Linux, amd64 Stack Trace: java.lang.ArrayIndexOutOfBoundsException: Index -1 out of bounds for length 8 at org.basex.query.var.QueryStack.set(QueryStack.java:111) at org.basex.query.QueryContext.set(QueryContext.java:535) at org.basex.query.expr.gflwor.Let$LetEval.next(Let.java:146) at org.basex.query.expr.gflwor.GFLWOR$1.next(GFLWOR.java:78) at org.basex.query.scope.MainModule$1.next(MainModule.java:55) at org.basex.core.cmd.AQuery.run(AQuery.java:90) at org.basex.core.Command.run(Command.java:233) at org.basex.core.Command.execute(Command.java:93) at org.basex.api.client.LocalSession.execute(LocalSession.java:131) at org.basex.api.client.Session.execute(Session.java:36) at org.basex.core.CLI.execute(CLI.java:94) at org.basex.BaseX.<init>(BaseX.java:109) at org.basex.BaseX.main(BaseX.java:45)
Query "wrapper.xqy" executed in 938.59 ms. ```
On 22/07/25, Yitzhak Khabinsky via BaseX-Talk (basex-talk@mailman.uni-konstanz.de) wrote:
Hi Rory,
It is very easy to run XSLT transformations directly in BaseX.
BaseX has a built-in XSLT module for that. By default it supports XSLT 1.0 standard. If needed you can extend it up to XSLT 4.0 via Saxon.
First, you need to prepare a tiny XQuery file for that.\ It accepts two parameters:
- $input, to specify input XML file
- $stylesheet, to specify XSLT file
In my example the result output file gets calculated name with a specific suffix: "_output.xml" But it could be a 3rd parameter too.
xquery_xslt.qy
declare variable $input as xs:string external; declare variable $stylesheet as xs:string external;
let $output := substring-before($input, ".") || "_output.xml" return xslt:transform($input, $stylesheet) -> file:write($output, .)
Second, launch XSLT transformation at the command prompt: basex.bat -b $input="path/to/input.xml" -b $stylesheet="path/to/transform.xslt" "path/to/xquery_xslt.qy"
Regards, Yitzhak Khabinsky
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))
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))
Dear Christian, Martin
Thank you very much for this invaluable info, and everyone's general helpfulness which is very much appreciated.
I can confirm that with the tweak below to wrapper.xqy, the
basex -o output.xml -b input=small.xml -b stylesheet=transform.xsl wrapper.xqy
command works great.
The command line xslt:transform invocation below failed, however, with:
Illegal character in opaque part at index 15: xslt:transform("small.xml", "transform.xsl")
Best wishes, Rory
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))
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))
This:
basex -o output.xml "xslt:transform('small.xml', 'transform.xsl')"
worked perfectly. Apologies -- I should have consider the quoting issue.
Thank you very much, Rory
On 23/07/25, Christian Grün (cg@basex.org) wrote:
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))
basex-talk@mailman.uni-konstanz.de