xquery - XQuery 集合 - 无法从目录中获取多个文件
问题描述
我正在尝试从在 XML 元素中具有特定字符串的目录中获取所有文件名。我为此使用此代码:
for $x in collection('file:///C:/Sricpts/Software20180101-V1.1.1/workspace/Data_PreProcessing?select=*.xml')
where matches($x, 'INSERT INTO')
return $x
但是,当我运行代码时,它会给出该错误:
[FODC0002] Resource 'C:/Program Files (x86)/BaseX/file:/file:///C:/Sricpts/Software20180101-V1.1.1/workspace/Data_PreProcessing?select=*.xml' does not exist.
我怎么解决这个问题?
非常感谢!
解决方案
如果使用 BaseX,则无需指定文件过滤器。指定目录中出现的所有 XML 文档都将添加到您的集合中:
for $x in collection('file:///C:/Sricpts/Software20180101- V1.1.1/workspace/Data_PreProcessing')
where matches($x, 'INSERT INTO')
return $x
如果您想更好地控制要选择的文档,可以利用File Module:
let $root := 'C:\Sricpts\Software20180101- V1.1.1\workspace\Data_PreProcessing'
for $path in file:list($root, true(), '*.xml')
let $doc := doc($root || $path)
where matches($doc, 'INSERT INTO')
return $doc
推荐阅读
- terraform - 如何使用具有不同值的 null 代替默认值
- python - 无法使用多处理来利用 100% 的 CPU/内核
- android - 错误:FirebasePerformancePlugin 只能用于 Android 应用程序项目。不能在图书馆?
- google-sheets-api - 使用 google sheet create api 创建受保护列时出错
- opencv3.0 - 不使用 OpenCV 编译,而是保存到 predictions.png
- c# - c# 无法访问具有类属性的 foreach 循环
- ios - 是否可以在不使用 CoreLocation 的情况下在 IOS 中获取位置?我们可以使用网络提供商获取它吗?
- php - Docker alpine 图像上的 PHP HTTP 扩展
- java - java程序星球使用枚举
- r - 从 Date 类变量中删除 NA