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


Reply via email to