Hi Yitzhak,

If your XSLT transformation returns something else than an XML document, you should use xslt:transform-text [1] to receive the generated result as string.

Hope this helps,
Christian



On Sun, Jun 1, 2025 at 9:55 PM <ykhabins@bellsouth.net> wrote:
Hello,

It seems that BaseX 12.0 beta 2686758, and later, is tripping on the XSLT transformation that outputs text, not XML.
I am using SaxonHE12-5J.

Even the following XQuery setting is not helping.
declare option output:method 'text';

IMHO, BaseX should read the output:method attribute from an XSLT and handle it properly.
method? = "xml" | "html" | "xhtml" | "text" | "json" | "adaptive" | eqname
https://qt4cg.org/specifications/xslt-40/Overview.html#id-xsl-output-declaration

Below is an easy repro.

Process3.xslt is working (xsl:output method="xml")
Process2.xslt is NOT working (xsl:output method="text")

Error:
Stopped at C:/Program Files (x86)/BaseX/src/file, 10/15:
[FODC0002] "" (Line 1): Content is not allowed in prolog.

XQuery
=============
(: Outputs the result as xml. :)
declare option output:method 'text';

declare variable $input as xs:string := 'e:\Temp\BaseX_XSLT\Input2.xml';
declare variable $stylesheet as xs:string := 'e:\Temp\BaseX_XSLT\Process2.xslt';

xslt:transform($input, $stylesheet)

input2.xml
==============
<dummy>text</dummy>

Process3.xslt
=================
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:output method="xml" omit-xml-declaration="yes"/>

        <xsl:template match="/dummy">
                <xsl:copy-of select="."/>
        </xsl:template>
</xsl:stylesheet>

Process2.xslt
================
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:output method="text" omit-xml-declaration="yes"/>

        <xsl:template match="/dummy">
                <xsl:value-of select="."/>
        </xsl:template>
</xsl:stylesheet>