1

I have XML files in eXist-db in the following collections:

  • /db/OCR/Everest_Bank/(xml files are here)
  • /db/OCR/Siddhartha_Bank/(xml files are here)
  • /db/OCR/ABC_Bank/(xml files are here)

I want to run an XQuery in the /db/OCR collection across all the "banks" satisfying a condition and want to return the name of the bank which satisfied the condition. I wrote a query but am stuck in the return part of the FLWOR expression.

declare default element namespace 'http://www.xbrl.org/2003/instance';
declare namespace ifrs = 'http://xbrl.ifrs.org/taxonomy/2013-03-28/ifrs';

for $x in collection("/db/OCR")
let $z := $x/xbrl/ifrs:Assets (: want to have query in assets of all files in the banks :)
return
    if (exists($z) and xs:integer($z/text())>9999999) 
    then ???

Now how can I return the collection name like "Everest_Bank" for the results that satisfy my conditions? Please help.

4

1 回答 1

2

The generic and portable way to do this on XQuery engines is:

document-uri( root($z) )

will give you the URI of the document in eXist-db; the collection information is in the URI;

the eXist-db specific way (warning: not portable to other XQuery implementations) is:

util:collection-name( $z )

in the http://exist-db.org/xquery/util function namespace.

于 2013-08-02T17:43:57.623 回答