Hi Buzz,
BaseX allows you to address multiple databases in one query. Your
query could e.g. look as follows:
let $zzz := collection('lookup')//item[@id =$attr0]/text()
for $rep in collection('coll')/Report
let $attr0 := $rep/@attr0
return replace value of node $rep/@attr1 with $zzz
You may speed up your query a little by using db:open() instead of
collection() (the latter one will additionally look up local files if
there’s no database with the given name). To ensure that your query
uses the index structures of the lookup database, you can have a look
at the InfoView in the GUI, or turn on the query info on command line
(-V).
Hope this helps,
Christian
> _______________________________________________
> Hello All,
>
> I'm relatively new to basex and xquery - but am using basex as a large
> report repository.
>
> I'd like to try and perform the following xquery - but with some
> intermediate steps:
>
> xquery for $rep in collection('coll')/Report let $attr0 := $rep/@attr0
> return (replace value of node $rep/@attr1 with 'zzz')
>
>
> The actual value represented by 'zzz' above must be based on a separate
> (physical) database lookup for each attribute value $attr0 in the collection
> ( i.e. the values of attr1 is a (non-trivial lookup) function of attr0.
>
> Is this a scenario in which multiple queries would have to be made based on
> the number of documents in the collection ?
>
> Perhaps there is some slick way of including a call out to some method to
> such that the 'zzz' above is replaced with something like:
> JavaModule.doLookup($attr0) ?
>
> I'm executing xquery from a jruby application so either the ruby or the java
> client can be used (perhaps that is somewhat irrelevant).
>
> Thanks in advance for any suggestions,
>
> Buzz
>
>
>
>
> BaseX-Talk mailing list
> BaseX-Talk@mailman.uni-konstanz.de
> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
>