Question

I have a directory with a bunch of XML documents and want to put all of them into a container. In other words, I need to do something like this:

dbxml> putDocument tests/*.xml

I have written a GUI program to do that but the host server does not have X-windows installed, so must be in command line.

Was it helpful?

Solution 3

Ended up using a script that lists files and puts everything into the DB.

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top