多个文件输入? [英] Multiple file inputs?
问题描述
在XSLT文档中,是否可以遍历当前目录中的一组文件?
Within an XSLT document, is it possible to loop over a set of files in the current directory?
我的情况是我有一个完整的xml目录需要进行一些分析才能生成报告的文件。我的样式表在单个文档上运行很好,但是我想扩展它而不需要另一个工具来合并xml文档。
I have a situation where I have a directory full of xml files that need some analysis done to generate a report. I have my stylesheet operating on a single document fine, but I'd like to extend that without going to another tool to merge the xml documents.
我在考虑以下几点:
<xsl:for-each select="{IO Selector Here}">
<xsl:variable select="document(@url)" name="contents" />
<!--More stuff here-->
</xsl:for-each>
推荐答案
在XSLT 2.0和Saxon中,你可以做这与集合()
函数:
In XSLT 2.0, and with Saxon, you can do this with the collection()
function:
<xsl:for-each select="file:///path/to/directory">
<!-- process the documents -->
</xsl:for-each>
参见 http://www.saxonica.com/documentation/sourcedocs/collections.html 了解更多详情。
在XSLT 1.0中,您必须创建一个索引,列出要使用单独工具处理的文档。您的环境可能提供这样的工具;例如,Cocoon有一个创建这样一个索引的目录生成器。但不知道你的环境是什么,很难知道推荐什么。
In XSLT 1.0, you have to create an index that lists the documents you want to process with a separate tool. Your environment may provide such a tool; for example, Cocoon has a Directory Generator that creates such an index. But without knowing what your environment is, it's hard to know what to recommend.
这篇关于多个文件输入?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!