Hello,
I am using the latest BaseX 11.0 final.
I am running an XSLT 3.0 transformation, by using SaxonHE12-4J, and hit a snag with it.
The goal of the XSLT is to split large input XML file into few smaller XML files. The test case files: XML, XSLT, and xq, are below.
The XSLT transformation is working as expected, producing multiple output files on the file system. Alas, BaseX GUI emits the following error: Error: Stopped at C:/Program Files (x86)/basex/src/xslt_transform30.xq, 6/15: [FODC0002] "" (Line -1): Premature end of file.
My XSLT is a little bit unusual. It is leveraging powerful XSLT 3.0 functionality. It doesn't have one single output, but many output files directly to the file system, IMHO, that's the reason for the BaseX error. BaseX is expecting at least some output back from the XSLT transformation.
For comparison, the Oxygen XML IDE is working as expected with such XSLT.
What could be done to fix it? May be BaseX behavior needs some adjustment, so it will accept blank output as normal for the xslt:transform($input, $stylesheet)?
BaseX is famous for its latest standards support. Modern XSLT versions, i.e. above XSLT 1.0, support multiple outputs.
_xslt_transform30.xq =========================================== xquery version "4.0";
declare variable $input as xs:string external; declare variable $stylesheet as xs:string external;
xslt:transform($input, $stylesheet) ===========================================
Input.xml =========================================== <doc title="example document"> <chapter title="chapter 1"> <page>page 1</page> <page>page 2</page> </chapter> <chapter title="chapter 2"> <page>page 3</page> </chapter> </doc> ===========================================
SplitProcess.xslt =========================================== <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:math="http://www.w3.org/2005/xpath-functions/math" exclude-result-prefixes="xs math" version="3.0" expand-text="yes"> <xsl:output indent="yes" method="xml"/>
<!-- output directory --> <xsl:param name="directory" select="'c:/Temp/XSLT30/Split up a file into several files'"/>
<xsl:template match="/"> <xsl:apply-templates select="doc/chapter/page"/> </xsl:template>
<xsl:template match="page"> <xsl:result-document href="file:///{$directory}/page{position()}.xml"> <xsl:copy-of select="root(snapshot())"/> </xsl:result-document> </xsl:template> </xsl:stylesheet> ===========================================
Regards, Yitzhak Khabinsky
On 01/07/2024 15:04, ykhabins@bellsouth.net wrote:
Hello,
I am using the latest BaseX 11.0 final.
I am running an XSLT 3.0 transformation, by using SaxonHE12-4J, and hit a snag with it.
The goal of the XSLT is to split large input XML file into few smaller XML files. The test case files: XML, XSLT, and xq, are below.
The XSLT transformation is working as expected, producing multiple output files on the file system. Alas, BaseX GUI emits the following error: Error: Stopped at C:/Program Files (x86)/basex/src/xslt_transform30.xq, 6/15: [FODC0002] "" (Line -1): Premature end of file.
My XSLT is a little bit unusual. It is leveraging powerful XSLT 3.0 functionality. It doesn't have one single output, but many output files directly to the file system, IMHO, that's the reason for the BaseX error. BaseX is expecting at least some output back from the XSLT transformation.
For comparison, the Oxygen XML IDE is working as expected with such XSLT.
What could be done to fix it?
I think your analysis is correct, it is not the use of XSLT 3 and xsl:result-document that fails, but the lack of a primary result document; as a workaround, it seems you can do e.g.
<xsl:template match="/"> <dummy/> <xsl:apply-templates select="doc/chapter/page"/> </xsl:template>
I am sure Christian will look into fixing it if JAXP allows it.
A comment concerning the big picture. I regard BaseX as an exquisite - and in many respects unique - platform of data integration. Therefore I would consider the most flexible and unconstrained support for XSLT 3 as a high priority, worth extra miles, if necessary. Kind regards, Hans-Jürgen Rennau Am Dienstag, 2. Juli 2024 um 20:37:14 MESZ hat Christian Grün christian.gruen@gmail.com Folgendes geschrieben:
as a workaround, it seems you can do e.g. <xsl:template match="/"> <dummy/> <xsl:apply-templates select="doc/chapter/page"/> </xsl:template>
This would have been my suggestion, too. Thanks.
A while ago, Christian already provided xslt:transform-report() [1] that still used the same (I think) JAXP interface that xslt:transform() uses and that can’t deal with initial templates, secondary outputs, etc.
xslt:transform-report() was sponsored by us (we reclaimed the 4-digit amount from one of our customers).
When asking for this feature, I also suggested that someone [2] implement the full transform() function [3]. At that time he preferred not to since this will certainly require much more effort than was necessary for xslt:transform-report(). I’m afraid that unless someone (or a group of sponsors) funds this development, it will not happen any time soon. Alas, we as le-tex are unable to fund the full exercise, and we don’t have a customer around that urgently needs this feature and has sufficiently deep pockets.
Gerrit
[1] https://docs.basex.org/main/XSLT_Functions#xslt:transform-report [2] Christian [3] https://www.w3.org/TR/xpath-functions-31/#func-transform
On 03.07.2024 09:37, Hans-Juergen Rennau wrote:
A comment concerning the big picture.
I regard BaseX as an exquisite - and in many respects unique - platform of data integration. Therefore I would consider the most flexible and unconstrained support for XSLT 3 as a high priority, worth extra miles, if necessary.
Kind regards, Hans-Jürgen Rennau
Am Dienstag, 2. Juli 2024 um 20:37:14 MESZ hat Christian Grün christian.gruen@gmail.com Folgendes geschrieben:
as a workaround, it seems you can do e.g.
<xsl:template match="/"> <dummy/> <xsl:apply-templates select="doc/chapter/page"/> </xsl:template>
This would have been my suggestion, too. Thanks.
basex-talk@mailman.uni-konstanz.de