niXforums Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
·  nixdoc.net ·  man pages ·  Linux HOWTOs ·  FreeBSD Tips ·  Forums
navigation Forum index » Databases » Berkeley DB
Query for document names in dbxml Shell
Post new topic   Reply to topic Page 1 of 1 [4 Posts] View previous topic :: View next topic
Author Message
watch1
*nix forums beginner


Joined: 04 May 2006
Posts: 3

PostPosted: Thu May 04, 2006 4:37 am    Post subject: Query for document names in dbxml Shell Reply with quote

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?
Back to top
Ron
*nix forums Guru Wannabe


Joined: 01 Apr 2005
Posts: 157

PostPosted: Thu May 04, 2006 3:02 pm    Post subject: Re: Query for document names in dbxml Shell Reply with quote

The following FAQ entry discusses how to do this:

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

Ron
Berkeley DB
Oracle Corporation
Back to top
watch1
*nix forums beginner


Joined: 04 May 2006
Posts: 3

PostPosted: Thu May 04, 2006 10:51 pm    Post subject: Re: Query for document names in dbxml Shell Reply with quote

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.
Back to top
watch1
*nix forums beginner


Joined: 04 May 2006
Posts: 3

PostPosted: Thu May 04, 2006 10:55 pm    Post subject: Re: Query for document names in dbxml Shell Reply with quote

Does anyone know when the expression:

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

can be used to obtain a list of document names?
Back to top
Google

Back to top
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [4 Posts] View previous topic :: View next topic
The time now is Sat Jan 10, 2009 3:05 am | All times are GMT
navigation Forum index » Databases » Berkeley DB
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts Very slow query Michael Sutter MySQL 0 Fri Jul 21, 2006 1:10 pm
No new posts Column info without executing query Dan Strömberg PostgreSQL 10 Thu Jul 20, 2006 6:21 pm
No new posts recursive query Jürg Schaufelberger Server 1 Thu Jul 20, 2006 6:06 pm
No new posts problem updatenodes in dbxml mahdieh Berkeley DB 0 Thu Jul 20, 2006 5:15 pm
No new posts How to query on part of a date column? Barry Newton MySQL 4 Thu Jul 20, 2006 5:02 pm

Car Loan | Meeting Rooms | PunBB forum hosting | Credit Cards | Free Ringtone
Copyright © 2004-2005 DeniX Solutions SRL
 
Other DeniX Solutions sites: Unix/Linux blog |  electronics forum |  medicine forum |  science forum | 
Privacy Policy


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1581s ][ Queries: 16 (0.0778s) ][ GZIP on - Debug on ]