Reputation: 153
Can I use XQuery to query all XML files under a specific directory? All the XML files have the same structure.
Also, from what I have seen you can XQuery many files but you need to write the names of them in the query. In my case, I need to query 500 XML files with quite different names each. So Is there a way I can say:
for $x in doc("ALL files under a specific directory")/Foo
return $x/Something
Upvotes: 15
Views: 6734
Reputation: 243529
Use the collection()
function.
In its Saxon implementation, one can use:
collection('file:///a/b/c/d?select=*.xml')
Upvotes: 11
Reputation: 677
Use the collection() function.
In its Saxon implementation, one can use: collection('file:///a/b/c/d?select=*.xml')
I tried this example under Windows 7 with Saxon HE 9.5.1.5J. The URI then takes a different form, for example: file:/C:/work/GIT/managedSoftwareDoc/experimenting/xQuery?select=*.xml
Upvotes: 0
Reputation: 8422
For MarkLogic:
for $x in cts:search(fn:doc()/Foo, cts:directory-query("/target/directory/"))
return $x/Something
Upvotes: 1