遍历 zorba 中 xml 个文件的目录

Iterating through a directory of xml files in zorba

我有一个名为 auction 的目录,其中包含 xml 个文件的列表。 如何创建一个脚本来遍历每个文件并执行操作。我正在尝试使用 collection(),但它不起作用。

for $relpath in collection("auction") for $b in $relpath/people/person[@id = "person0"] return $b/name/text()

请帮忙。

如有需要,将提供更多信息

答案是在这里找到的: https://groups.google.com/forum/#!topic/zorba-users/8W2xOQ2j0Vw

修改它以适合我的目的。举例如下:

import module namespace file="http://expath.org/ns/file";

for $relpath in file:list("auction", fn:true(), "*.xml")

let $abspath := fn:concat("auction/", $relpath)

for $b in doc($abspath)/people/person[@id = "person0"] return $b/name/text()

首先需要导入模块使用,里面有list功能,显示所有内容。 然后迭代可以遍历每个文件并将其作为文档打开。但是,文件夹的名称需要与文件名连接