My (pure) suspicion is that the use of document-uri
, while processing a collection, fails, see https://www.saxonica.com/html/documentation12/functions/fn/document-uri.html for some explanation.
So instead of
<xsl:for-each select="collection(concat($xmldirpath, '?select=*.xml;recurse=yes'))">
<xsl:variable name="file" select="fn:ditafilepath(document-uri(.))"/>
I would try
<xsl:for-each select="collection(concat($xmldirpath, '?select=*.xml;recurse=yes'))">
<xsl:variable name="file" select="fn:ditafilepath(base-uri(.))"/>
or instead of collection
I would use uri-collection
and then use <xsl:variable name="file" select="fn:ditafilepath(.)"/>
and process doc(.)
e.g. with wrapping <xsl:for-each select="doc(.)"><xsl:result-document href="{$filePath}" method="xml" encoding="UTF-8" indent="no">..</xsl:result-document></xsl:for-each>
or push doc(.)
through a template with <xsl:apply-templates select="doc(.)"/>
where you have <xsl:template match="/"><xsl:result-document href="{$filePath}" method="xml" encoding="UTF-8" indent="no">...</xsl:result-document></xsl:template>
.
But I haven't run any code, the error might still result from some very different use of XSLT or the Python API. Only I think the XSLT as shown doesn't work in Saxon 12 with the known change for document-uri
no longer working for documents in collections, whether it is SaxonC and the Python API or Saxon Java.