下面的 XSLT 根据需要创建结果文档,但有一个例外:结果文档最终位于调用样式表的目录中。我希望结果文档位于找到它的位置(即用转换版本覆盖自身)。
我怎样才能做到这一点?
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    version="2.0" xpath-default-namespace="http://www.w3.org/1999/xhtml">
    <xsl:template match="/">
        <xsl:for-each select="collection(iri-to-uri('file:///home/paul/Text/?select=*.xhtml'))">
            <xsl:variable name="filename">
                <xsl:value-of select="tokenize(document-uri(.), '/')[last()]"/>
            </xsl:variable>
            <xsl:result-document indent="yes" method="xml" href="{$filename}">
                <xsl:apply-templates/>
            </xsl:result-document>
        </xsl:for-each>
    </xsl:template>
    <xsl:template match="node()|@*">    
        <xsl:copy>
            <xsl:apply-templates select="node()|@*"/>
        </xsl:copy>
    </xsl:template>
    <!-- transform templates removed -->
</xsl:stylesheet>