I forgot to mention: I am using BaseX 9.2.3 and the databases both have a text and an attribute index that are "UPTODATE: true".
Am Mittwoch, den 10.07.2019, 13:17 +0000 schrieb Beck, Julia:
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