Hi Yitzhak,
 
sorry - BaseX does not support the "-it" option.
 
However, if you can modify the stylesheet, you could add a root template that refers to the initial template:
 
    <xsl:template match="/">
      <xsl:call-template name="xsl:initial-template"/>
    </xsl:template>
 
Also note that you might want to use function xslt:transform-text rather than xslt:transform, otherwise BaseX will expect the stylesheet to return an XML document, which your sample stylesheet does not do.
 
Adding the template could even be done dynamically, like so:
 
    declare namespace xsl = "http://www.w3.org/1999/XSL/Transform";
    let $stylesheet := doc("stylesheet.xsl")/*
    let $stylesheet-with-initial-template := document {
      element {$stylesheet/node-name()} {
        $stylesheet/@*,
        $stylesheet/node(),
        <xsl:template match="/">
          <xsl:call-template name="xsl:initial-template"/>
        </xsl:template>
      }
    }
    return xslt:transform-text(<dummy/>, $stylesheet-with-initial-template)
 
Hope this helps.
 
Best regards,
Gunther
Gesendet: Donnerstag, 4. Juni 2026 um 16:15
Von: "Yitzhak Khabinsky via BaseX-Talk" <basex-talk@mailman.uni-konstanz.de>
An: basex-talk@mailman.uni-konstanz.de
Betreff: [basex-talk] XSLT Module, how to specify XSLT's Initial Template name
Hello,

I am using BaseX 12.4 and its XSLT Module.
The XSLT engine is SaxonHE13-0J, so the XSLT 3.0 standard could be used!

My XSLT needs to process XML files in a directory on the file system.
The XSLT is implementing a so called Modified Identity Transform pattern.
Unfortunately, it seems it is impossible to pass "-it", i.e. Initial
Template name parameter.

I tried 2 lines XQuery as follows:

XQuery
==========
declare variable $stylesheet as xs:string external;
xslt:transform("<dummy/>", $stylesheet, { "-it": "xsl:initial-template" })

The XSLT is using an Initial Template <xsl:template
name="xsl:initial-template">
So, I tried to pass it in BaseX as a parameter to no avail.

The XSLT is working properly in Oxygen XML IDE when the "-it" parameter is
specified.

Please see below a full repro.

XML files have the following (simplified) structure:
====================================================
<root>
<body>
<text>
<text>second level text</text>
<text>second level text</text>
</text>
</body>
</root>

XSLT
===========
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl=http://www.w3.org/1999/XSL/Transform
version="3.0">
<xsl:output indent="yes" method="xml"/>

<xsl:mode on-no-match="shallow-copy"/>

<xsl:param name="input_dir" select="'file:///c:/XSLT30/Process Multiple
XML Files?select=*.xml'"/>
<xsl:param name="output-dir" select="'file:///c:/XSLT30/Process Multiple
XML Files/Output/'"/>

<xsl:template name="xsl:initial-template">
<xsl:for-each select="collection($input_dir)">
<xsl:variable name="input_fileName"
select="tokenize(base-uri(.), '/')[last()]"/>
<xsl:variable name="output_fileName" select="'new_' ||
$input_fileName"/>

<xsl:result-document href="{$output-dir || $output_fileName}">
<xsl:apply-templates />
</xsl:result-document>
</xsl:for-each>
</xsl:template>

<xsl:template match="text/text">
<comment>
<xsl:apply-templates/>
</comment>
</xsl:template>
</xsl:stylesheet>



Regards,
Yitzhak Khabinsky



Regards,
Yitzhak Khabinsky