dbTalk Databases Forums  

How to use @dbxml:name in an XQuery in DBXML?

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


Discuss How to use @dbxml:name in an XQuery in DBXML? in the comp.databases.berkeley-db forum.



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

Default How to use @dbxml:name in an XQuery in DBXML? - 02-24-2005 , 03:02 AM






Hello,

I am desperately trying to select a record by name in an XML container.

I want to select a record using something like:
collection("current.dbxml")/*[@dbxml:name="pump_def"]
It doesn't find the record.

If I do
collection("current.dbxml")/*
I can see it. And if I use
lookupIndex(qc, uri, name, strategy)
with
uri = http://www.sleepycat.com/2002/dbxml
name = name
strategy = "unique-node-metadata-equality-string
I can see the record I am looking for, with the name 'pump_def'.

I tried to add the dbxml namespace to qc, it doesn't help.

It works if I add the dbxml:name and dbxml namespace in the XML
document that I store, but then, it selects the records based on that
attribute, and not on the name I gave when I put() the record.

Any ideas?

I am using DBXML 2.0.7, in C++ (gcc), on Solaris.

Thanks in advance.
Florian Fischer


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

Default Re: How to use @dbxml:name in an XQuery in DBXML? - 02-28-2005 , 12:57 PM







Grimbal wrote:
Quote:
Hello,

I am desperately trying to select a record by name in an XML
container.

I want to select a record using something like:
collection("current.dbxml")/*[@dbxml:name="pump_def"]
It doesn't find the record.

If I do
collection("current.dbxml")/*
I can see it. And if I use
lookupIndex(qc, uri, name, strategy)
with
uri = http://www.sleepycat.com/2002/dbxml
name = name
strategy = "unique-node-metadata-equality-string
I can see the record I am looking for, with the name 'pump_def'.

I tried to add the dbxml namespace to qc, it doesn't help.

It works if I add the dbxml:name and dbxml namespace in the XML
document that I store, but then, it selects the records based on that
attribute, and not on the name I gave when I put() the record.
There are several ways to do what you want.
If you just want the named document itself,
you can use a query like:
doc('current.dbxml/pump_def')
Note the use of doc() vs collection()

The way to name a document using the dbxml:name metdata
item is this:


collection('current.dbxml')/*[dbxml:metadata('dbxml:name')='pump_def']

In release 2.0, BDB XML metadata is no longer treated as an attribute
of the root element. It is separate from the actual XML, and can
be addressed using the dbxml:metdata() function built into the XQuery
mechanism. If you define your own metadata, remember to bind
your namespace prefix during your queries if you use one for the
metadata.

Regards,

George



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

Default Re: How to use @dbxml:name in an XQuery in DBXML? - 03-01-2005 , 11:44 AM



Ah... That explains it. I saw plenty of examples with @dbxml:name,
but none worked.

But both your examples work fine. Thanks a lot.

Florian


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 - 2013, Jelsoft Enterprises Ltd.