Xquery over all collections

Wednesday, 6 February 2013 · 4 messages · last reply 24 Feb 2013
P
pw6 Feb 2013 01:13 #
Hello List I am wanting to query all collections in BaseX 7.5 without hard coding the names of each collection in my xquery. I can list the collections with db:list() but am struggling to get something like let $r := (collection('A'), collection('B'), collection('C'))/xml/indicator[code='myCode'] I can use db:list() to get all documents in all collections in this way:
let $q := for $a in (db:list())
          let $e :=string-join( $a, ',')
          return $e
let $z := for $x in $q
              return db:open($x)
for $r in $z
    return $r
Can anyone please suggest a way of using db:list and other functions in xquery to perform a query on all collections. Cheers Peter
LK
Lukas Kircher6 Feb 2013 08:40 #
Hi Peter, for example, if I look for all *<br>* elements over all documents/collections: *for $d in db:list()* *return collection($d)//br* * * Is this what you were looking for? Cheers, Lukas
Quoted text · pw · 4 lines
On Wed, Feb 6, 2013 at 1:13 AM, <pw at themail.co.uk> wrote: > let $r := (collection('A'), collection('B'), > collection('C')) >
P
pw6 Feb 2013 23:43 #
Hi Lukas That is exactly what I was looking for ... :-) I was clearly just thinking it was more complicated than it really was Thanks Peter
Quoted text · Lukas Kircher · 30 lines
> > > >---- Original Message ---- >From: lukaskircher1 at gmail.com >To: pw at themail.co.uk >Subject: Re: [basex-talk] Xquery over all collections >Date: Wed, 6 Feb 2013 08:40:07 +0100 > >>Hi Peter, >> >>for example, if I look for all *<br>* elements over all >>documents/collections: >> >>*for $d in db:list()* >>*return collection($d)//br* >>* >>* >>Is this what you were looking for? >> >>Cheers, >>Lukas >> >> >>On Wed, Feb 6, 2013 at 1:13 AM, <pw at themail.co.uk> wrote: >> >>> let $r := (collection('A'), collection('B'), >>> collection('C')) >>> >>
P
pw24 Feb 2013 11:59 #
Hi Lukas Sorry to be so long in actually picking this up... but I think that let $r := (collection('A'), collection('B'),collection('C'))//br is a lot faster than
let $r := for $d in db:list()
          return collection($d)//br
Any thoughts? Cheers Peter
Quoted text · pw · 30 lines
> > > >---- Original Message ---- >From: lukaskircher1 at gmail.com >To: pw at themail.co.uk >Subject: Re: [basex-talk] Xquery over all collections >Date: Wed, 6 Feb 2013 08:40:07 +0100 > >>Hi Peter, >> >>for example, if I look for all *<br>* elements over all >>documents/collections: >> >>*for $d in db:list()* >>*return collection($d)//br* >>* >>* >>Is this what you were looking for? >> >>Cheers, >>Lukas >> >> >>On Wed, Feb 6, 2013 at 1:13 AM, <pw at themail.co.uk> wrote: >> >>> let $r := (collection('A'), collection('B'), >>> collection('C')) >>> >>

⚡Generated with XQuery