1

以下の XSLT は、1 つの例外を除いて、必要に応じて結果ドキュメントを作成します。結果ドキュメントは、スタイルシートが呼び出されたディレクトリに配置されます。結果ドキュメントが見つかった場所にあるようにしたい (つまり、変換バージョンでそれ自体を上書きする)。

どうやってやるの?

<?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>
4

1 に答える 1