Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XQuery all files under a specific directory?

Tags:

xml

xquery

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
like image 832
Nick J. Avatar asked Apr 08 '11 23:04

Nick J.


People also ask

How do I query XML data in XQuery?

Querying in an XQuery contextIf your query invokes an XQuery expression directly, you must prefix it with the case-insensitive keyword XQUERY. To retrieve all of the XML documents previously inserted into the INFO column, you can use XQuery with either db2-fn:xmlcolumn or db2-fn:sqlquery.

Where can I use XQuery?

It is used to retrieve information stored in XML format. XQuery for XML is similar as SQL for databases. It can be used on XML Databases, relational databases containing data in XML formats or XML documents.

What is XQuery HTML?

XQuery is About Querying XML XQuery is a language for finding and extracting elements and attributes from XML documents.

What is the extension for XQuery file?

NOTE: XQUERY files more commonly use the . XQ extension.


2 Answers

For MarkLogic:

for $x in cts:search(fn:doc()/Foo, cts:directory-query("/target/directory/"))
return $x/Something
like image 45
Dave Cassel Avatar answered Oct 16 '22 05:10

Dave Cassel


Use the collection() function.

In its Saxon implementation, one can use:

collection('file:///a/b/c/d?select=*.xml')
like image 108
Dimitre Novatchev Avatar answered Oct 16 '22 04:10

Dimitre Novatchev