dbTalk Databases Forums  

BDB XML collection vs. doc question.

comp.databases.berkeley-db comp.databases.berkeley-db


Discuss BDB XML collection vs. doc question. in the comp.databases.berkeley-db forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Bob
 
Posts: n/a

Default BDB XML collection vs. doc question. - 11-22-2005 , 09:21 AM






Hello,

I have been working with Berkeley DB XML for about a week and was able to
produce a working application! (See the P.S., below.)

My simple little application is actually part of a larger application that has
some data to be manipulated. My part of the overall scheme is driven by a
bash shell script (I'm on Linux) that invokes the dbxml utility to issue
queries.

The general approach is to record the data in XML format and use the dbxml
utility to run queries that load those XML files into a container
(collection? I am weak on the terminology) then use other queries (also via
the dbxml utility) to generate my output which is fed back into the larger
application.

But, even though it is all working, I am not sure *why* some things are the
way they are. Here is the main thing that puzzles me:

The following works (in that "scenarios" gets populated):
================================================== ==========
createcontainer autogen.dbxml
putdocument project 'project.xml' f
putdocument matches '<MATCHES>
{
for $pkg in doc("autogen.dbxml/project")/PROJECT/PKG_LIST/PACKAGE
....
}
</MATCHES>
' q

putdocument scenarios ' <SCENARIOS>
{
for $item in collection("autogen.dbxml")/MATCHES/ITEM
....
}
</SCENARIOS>
' q
================================================== ==========
Using "setverbose 2 2" I see that several elements were but into
<SCENARIO>...</SCENARIO>. Also the rest of my application works since there
is data to work with.

But the following fails (empty "scenarios"). It is only the final "for"
that differs.
================================================== ==========
createcontainer autogen.dbxml
putdocument project 'project.xml' f

putdocument matches '<MATCHES>
{
for $pkg in doc("autogen.dbxml/project")/PROJECT/PKG_LIST/PACKAGE
....
}
</MATCHES>
' q

putdocument scenarios ' <SCENARIOS>
{
for $item in doc("autogen.dbxml/matches")/MATCHES/ITEM
....
}
</SCENARIOS>
' q
================================================== ==========
Using "setverbose 2 2" I see that <SCENARIOS /> was created as an empty
element. The rest of my application gets no data to process.

So here is my question. In the above context, under what circumstances would
this work:
********for $item in collection("autogen.dbxml")/MATCHES/ITEM
but this fail:
********for $item in doc("autogen.dbxml/matches")/MATCHES/ITEM

Thanks,
Bob

----------------------
P.S. I have been hearing about XML for a few years now but never really
understood what it was good for. Suddenly I had an epiphany. I felt like
someone with a big pile of boards and nails who suddenly realized what a
hammer was good for!

Reply With Quote
  #2  
Old   
ron.cohen@gmail.com
 
Posts: n/a

Default Re: BDB XML collection vs. doc question. - 11-22-2005 , 03:24 PM






When the document named "matches" does not exist in the container
"autogen.dbxml," which is the case.

When you insert documents using a query, the BDB XML feature that
automatically generates document names is used, and the string provided
(in this case "matches") is just used as a prefix. This is because
this mechanism may create more than one document.

For example, in the shell:

dbxml> putDocument mat <root/> q
Document added, name = mat_2, content = <root/>

So, the actual document you want is not called "matches."
In fact, it is more likely that you have multiple documents that start
with "matches."

If you want to see the documents in a container, use this:
dbxml> getDocuments
NN documents found
dbxml> printNames

Regards,

George


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.