如何为文件夹中的所有文件运行Saxon XSLT

VSr*_*VSr 1 xslt saxon xslt-2.0 xslt-1.0

我有文件夹/子文件夹中的文件列表.如何运行单个XSLT来运行文件夹/子文件夹中的所有文件.是否可以在saxon命令行中使用?

我已经尝试过以下命令,但它不起作用:

 java -jar saxon9.jar -o:foldername -xsl:xslfilename.xsl
Run Code Online (Sandbox Code Playgroud)

非常感谢您的帮助.

Phi*_*yNJ 5

由于您使用的是Saxon,因此您可以使用xslt 2.0和该collection函数.

例如:

<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
    <xsl:for-each select="collection(concat('file:///c:/filesarehere', '?select=*.xml;recurse=yes'))">
        <!--process nodes-->
    </xsl:for-each>
</xsl:template>
Run Code Online (Sandbox Code Playgroud)

  • 当我这样做时,我通常使用`<xsl:template name ="main">`作为入口点,并在命令行上使用`-it:main`,以避免需要一个虚拟输入文档来匹配`匹配= "/"`.另外,我不知道"c:/ ..."是否作为集合URI,我会使用"file:/// c:/ ..." (4认同)