Mahadeva
Mahadeva

Reputation: 1637

XQuery in collection within some XML files

I am using eXist-db for XML file handling. I have a collection named /db/Sample/Mycollection. To iterate over all files in the collection I can use

for $x in collection("/db/Sample/Mycollection")
let $z:= ...
return ...

But in this collection I have files with filenames 2060.xml, 2061.xml, and so on. Now I want to query over first 10 files like 2060.xml to 2069.xml or any number of files. How can I achieve this? Is there any function that can achieve this?

Upvotes: 1

Views: 319

Answers (1)

Joe Wicentowski
Joe Wicentowski

Reputation: 5294

The subsequence() function is your friend. To query over only the first 10 files:

for $x in subsequence(collection("/db/Sample/Mycollection), 1, 10)

Upvotes: 1

Related Questions