Subject: [basex-talk] Finding document based on filename
Hello,
I would be having 100s of databases, with each
database having 100 XML documents. I want to devise an
algorithm, where given a part of XML file name, i want
to know which database(s) contains it, or null if
document is not currently present in any database. Based
on that, add current document into the database. This is
to always maintain latest version of a document in DB,
and remove the older version, while adding newer
version.
So far, only way I could come up with is:
for $db in all-databases:
open $db
$fileNames = list $db
for eachFileName in $fileNames:
if $eachFileName.contains(sub-xml
filename):
add to ret-list-db
return ret-list-db
Above algorithm, seems highly inefficient, Is there
any indexing, which can be done ? Do you suggest, for
each document insert, I should maintain a separate XML
document, which lists each file inserted etc.
Once, i get hold of above list of db, I would be
eventually deleting that file and inserting a latest
version of that file(which would have same sub-xml file
name). So, constant updating of this external document
also seems painful (Map be ?).
Also, would it be faster, using XQUERY script files,
thru java code, or using Java API for such operations ?
How do you all deal with such operations ?