Hi Julia,
Thanks for the report. I’ve opened an issue to track this down [1], and I’ll give you feedback once the bug has been fixed.
All the best from Konstanz, Christian
[1] https://github.com/BaseXdb/basex/issues/1696
On Wed, Jul 10, 2019 at 3:20 PM Beck, Julia J.Beck@ub.uni-frankfurt.de wrote:
Hello BaseX team,
I am struggeling with the enforce index pragma and get a "Improper use? Potential bug? Your feedback is welcome". So here is my feedback/question:
I have XML data describing books in several databases that also contain (potentially outdated) control numbers for authority data and I have an XML doc with a list of old numbers and their replacement (== new number). So I want to go through this list and replace the old numbers in my data with the new numbers. My XQuery works for each database on its own, but as soon as I provide a list of databases, I get a NullPointerException.
The xml doc with the authority numbers looks like this:
<gnds> <gnd> <old>gnd_4452199-6</old>; <new>gnd_2163369-1</new>; </gnd> <gnd> <old>gnd_16288049-2</old>; <old>gnd_4683522-2</old>; <new>gnd_1901229-9</new>; </gnd> .... </gnds>
The data in the databases looks like this:
rdf:RDF <edm:ProvidedCHO @rdf:about="..."> <edm:wasPresentAt @rdf:resource="gnd_4452199-6"/> <dc:contributor @rdf:resource="gnd_4683522-2"/> ... </edm:ProvidedCHO> ... </rdf:RDF>
In the XQuery, I left out the replacement part (which I thought to be the problem first, but the script already throws the error when I just want to have the new numbers printed). It works when I run it for "tmd" and "tes" individually. When I leave out the pragma it takes really long time (obviously not using the index). I more or less followed the 3rd example in http://docs.basex.org/wiki/Indexes#Enforce_Rewritings
let $old_gnds := doc("oldIds.xml")/gnds/gnd, $all_db := ("tmd","tes") for $gnd in $old_gnds/old/text() let $new := $gnd/../../new/text() for $db in $all_db for $attr in db:open($db)/rdf:RDF/*/*/@rdf:resource where (# db:enforceindex #) {$attr = $gnd} return $new
Best wishes, Julia
-- JULIA BECK Elektronische Dienste / FIDDK
Universitätsbibliothek Johann Christian Senckenberg Bockenheimer Landstraße 134-138 60325 Frankfurt am Main 069 798 39387