Comment mettre plusieurs documents dans un conteneur XML Berkeley DB?
-
28-10-2019 - |
Question
J'ai un répertoire avec un tas de documents XML et que vous souhaitez mettre tous dans un récipient. En d'autres termes, je dois faire quelque chose comme ceci:
dbxml> putDocument tests/*.xml
Je l'ai écrit un programme d'interface graphique pour le faire, mais le serveur hôte ne dispose pas de fenêtres X installé, doit donc être en ligne de commande.
La solution 3
Ended up using a script that lists files and puts everything into the DB.
Autres conseils
I do a similar thing when reloading certain XML docs into my current application DB. It helps if all of the files sharing a common naming convention. In python you would could use the following script to add doc001.xml to doc009.xml:
from bsddb3.db import *
from dbxml import *
#Load source files 001 - 009
sourceDir = 'C:/directory-containing-xml-docs'
fileRange = range(1,10)
for x in fileRange:
mycontainer = mymgr.openContainer("myDB.dbxml")
xmlucontext = mymgr.createUpdateContext()
xmlinput = mymgr.createLocalFileInputStream(sourceDir + "doc00" + str(x) + ".xml")
mycontainer.putDocument("doc00" + str(x) + ".xml", xmlinput, xmlucontext)
print 'Added: ' + str(x)
del mycontainer
print '1 - 9 Added'
Hope that helps
You could have a shell script write the list of XML files to another file and then call dbxml_load_container with the -f option.