我可能有点晚了,但很可能下面的XQuery会按照你的意愿行事,它会返回不包含特定元素的每个XML文件的路径:
let $path := "."
for $file in file:list( $path, true(), '*.xml')
let $path := $path || "/" || $file
where not(
exists(fetch:xml($path)/foo/bar[text() = "Text"])
)
return $path
如果您只对特定的XML文件感兴趣,或者不包含特定元素,则以下查询可能有用:
declare variable $path := "/Users/michael/Code/foo";
every $doc in file:list($path, true(), '*.xml') (: returns a sequence of file-names :)
=> for-each(concat($path,"/", ?)) (: returns a sequence of full paths to each file :)
=> for-each(fetch:xml#1) (: returns a sequence of documents :)
satisfies exists(
$doc/*/*[text() = "Text"]
)
希望这可以帮助 ;-)