如何使用 saxon 加载多个 xml 文件 [英] how to load multiple xml files with saxon

查看:41
本文介绍了如何使用 saxon 加载多个 xml 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 saxon 进行 xpath 查询,但我不知道要加载多个 xml 文件.

I want to use saxon for xpath queries but i don't know to load multiple xml files.

我正在尝试在 Windows 的命令行中使用 saxon

I'm trying to use saxon with command line from windows

我在撒克逊人手册中读到我可以使用命令:

I read in saxon manual that i can use the command:

Query.exe -s:myDataFile.xml -q:myQueryFile -o:myOutputFile

Query.exe -s:myDataFile.xml -q:myQueryFile -o:myOutputFile

但我不知道如何加载多个xml文件而不仅仅是一个

but i don't know how to load multiple xml files and not just one

我有很多 xml 文件 myDataFile1.xml、myDataFile2.xml、myDataFile3.xml ... 我想运行查询到所有这些文件 所以我想加载所有文件然后查询它们(我不想查询每个文件,然后连接结果)

edit: I have many xml files myDataFile1.xml, myDataFile2.xml, myDataFile3.xml ... and i want to run the query to alla these files So i want to load all all files and then query them (I don't want to query every single file and then concatenate the results)

推荐答案

使用标准的 XPath 2.0 函数 collection().

collection() 特定于撒克逊的实现的文档是 这里.

The documentation for the Saxon-specific implementation of collection() is here.

您可以使用标准的 XPath 2.x collection() 函数,在 Saxon 9.x 中实现

You can use the standard XPath 2.x collection() function, as implemented in Saxon 9.x

Saxon 实现允许在函数的 string-Uri 参数中使用搜索模式,因此您可以在目录路径之后指定任何以 report_ 然后有另外两个字符,然后以 .xml 结尾.

The Saxon implementation allows a search pattern to be used in the string-Uri argument of the function, thus you may be able to specify after the path of the directory a pattern for any filename starting with report_ then having two other characters, then ending with .xml.

示例:

这个 XPath 表达式:

This XPath expression:

collection('file:///c:/?select=report_*.xml')

选择位于 c:\ 中的每个 XML 文档的文档节点,该文件的名称以 report_ 开头,然后包含 0 个或多个字符,然后以.xml.

selects the document nodes of every XML document that resides in c:\ in a file with name starting with report_ then having a 0 or more characters, then ending with .xml.

这篇关于如何使用 saxon 加载多个 xml 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆