dbTalk Databases Forums  

Query for document names in dbxml Shell

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


Discuss Query for document names in dbxml Shell in the comp.databases.berkeley-db forum.



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

Default Query for document names in dbxml Shell - 05-03-2006 , 11:37 PM






I am new to Berkeley dbxml and xml/xpath/xquery in general. I have
succeeded in storing a document in a container. Now I want to query for
the document name. Reading various references there seems to be more
than one way to do this. I cannot get any of them to work:

1. "collection("foo")//*/@dbxml:id"

2. 'collection("foo")//*//@dbxml:name'

3. for $a in collection("foo") return dbxml:metadata("name", $a)

I either get 0 results or a query error.

Has anyone made this work?


Reply With Quote
  #2  
Old   
Ron
 
Posts: n/a

Default Re: Query for document names in dbxml Shell - 05-04-2006 , 10:02 AM






The following FAQ entry discusses how to do this:

http://dev.sleepycat.com/resources/faq_show.html?id=26

Ron
Berkeley DB
Oracle Corporation


Reply With Quote
  #3  
Old   
watch1
 
Posts: n/a

Default Re: Query for document names in dbxml Shell - 05-04-2006 , 05:51 PM



OK, this time it worked as advertised. In hindsight it all makes sense
now.

++++++++++++++++++++++++++++++++++++++++++++++++++ ++++
1. This works:

dbxml> openContainer etc.dbxml

dbxml> info
Default container name: etc.dbxml
Type of default container: WholedocContainer
Index Nodes: off
Shell and XmlManager state:
Transactional, no active transaction
Verbose: on
Query context state: LiveValues,Eager

dbxml> query '
for $a in collection() return dbxml:metadata("dbxml:name", $a) '
1 objects returned for eager expression '
for $a in collection() return dbxml:metadata("dbxml:name", $a) '


dbxml> print
MyName

dbxml>


++++++++++++++++++++++++++++++++++++++++++++++++++ ++++
2. This does not work (no default container):

dbxml> preload etc.dbxml

dbxml> info
No default container
Shell and XmlManager state:
Transactional, no active transaction
Verbose: on
Query context state: LiveValues,Eager

dbxml> query '
for $a in collection() return dbxml:metadata("dbxml:name", $a) '
stdin:4: query failed, Error: The default collection has not been set
[err:FODC0
002]

dbxml>


++++++++++++++++++++++++++++++++++++++++++++++++++ ++++
3. This works (no default container):

dbxml> preload etc.dbxml

dbxml> info
No default container
Shell and XmlManager state:
Transactional, no active transaction
Verbose: on
Query context state: LiveValues,Eager

dbxml> query '
for $a in collection("etc.dbxml") return dbxml:metadata("dbxml:name", $
a) '
1 objects returned for eager expression '
for $a in collection("etc.dbxml") return dbxml:metadata("dbxml:name", $
a) '


dbxml> print
MyName

dbxml>


++++++++++++++++++++++++++++++++++++++++++++++++++ ++++
3. This does not work for painfully obvious reasons [in hindsight] (no
default container):

dbxml> preload etc.dbxml

dbxml> info
No default container
Shell and XmlManager state:
Transactional, no active transaction
Verbose: on
Query context state: LiveValues,Eager

dbxml> query '
for $a in collection('etc.dbxml') return dbxml:metadata("dbxml:name", $
a) '
stdin:11: query failed, Error: Error in XQuery expression:
Unrecognized character 'e' (0x70) [err:XPST0003], line 2,
column 24

dbxml>


++++++++++++++++++++++++++++++++++++++++++++++++++ ++++

In all cases openContainer or preload must be called on the container
before the query is attempted. If the container is in another folder
you can specify the -h command line parameter to set the default folder
for dbxml or you can append the folder before the container name in the
openContainer, preload and collection functions. If you are using
Windows, the backslashes "\" in the path must be replaced by forward
slashes "/".

Ron - Thanks for the encouragement to try again.


Reply With Quote
  #4  
Old   
watch1
 
Posts: n/a

Default Re: Query for document names in dbxml Shell - 05-04-2006 , 05:55 PM



Does anyone know when the expression:

collection("foo")//*//@dbxml:name

can be used to obtain a list of document names?


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.