dbTalk Databases Forums  

Hepl with BDB XML Query

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


Discuss Hepl with BDB XML Query in the comp.databases.berkeley-db forum.



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

Default Hepl with BDB XML Query - 11-27-2005 , 12:06 PM






Hello,

I have some XML data that looks like this:

<SAMPLE>
<TEST>
<NAME>T1</NAME>
<DATA>data1</DATA>
<ALLOW>A</ALLOW>
<ALLOW>B</ALLOW>
</TEST>
<TEST>
<NAME>T2</NAME>
<DATA>data2</DATA>
<DENY>A</DENY>
<DENY>C</DENY>
</TEST>
<TEST>
<NAME>T3</NAME>
<DATA>data3</DATA>
</TEST>
</SAMPLE>

What Query would I use to select all TEST elements where

a) There is no "DENY" of "A".
This should select the TEST elements with NAMEs T1 and T3.

b) There is an "ALLOW" of "B".
This should select the TEST elements with NAME T1 only.

c) There is no "DENY" of "X".
This should select all three TEST elements.

d) There are no "ALLOW" elements at all. (i.e no specific ALLOW means
"allow all".)
This should select the test elements with NAMEs T2 and T3.

Is there a better way to structure the data?

Here is a start for "a)" above:

query '
<MATCHES>
{
for $t in doc("sample.dbxml/sample")/SAMPLE/TEST
where empty(doc(sample.dbxml/sample")/SAMPLE/TEST/[DENY/string()="A"])
return $t
}
</MATCHES>
'

Thanks.
Bob


Reply With Quote
  #2  
Old   
John Snelson
 
Posts: n/a

Default Re: Help with BDB XML Query - 11-28-2005 , 09:59 AM







Bob wrote:
Quote:
Hello,

I have some XML data that looks like this:

SAMPLE
TEST
NAME>T1</NAME
DATA>data1</DATA
ALLOW>A</ALLOW
ALLOW>B</ALLOW
/TEST
TEST
NAME>T2</NAME
DATA>data2</DATA
DENY>A</DENY
DENY>C</DENY
/TEST
TEST
NAME>T3</NAME
DATA>data3</DATA
/TEST
/SAMPLE

What Query would I use to select all TEST elements where

a) There is no "DENY" of "A".
This should select the TEST elements with NAMEs T1 and T3.
collection()/SAMPLE/TEST[not(DENY = "A")]

Quote:
b) There is an "ALLOW" of "B".
This should select the TEST elements with NAME T1 only.
collection()/SAMPLE/TEST[ALLOW = "B"]

Quote:
c) There is no "DENY" of "X".
This should select all three TEST elements.
See (a)

Quote:
d) There are no "ALLOW" elements at all. (i.e no specific ALLOW means
"allow all".)
This should select the test elements with NAMEs T2 and T3.
collection()/SAMPLE/TEST[empty(ALLOW)]

Quote:
Is there a better way to structure the data?
The structure of your data looks fine.

Hope this gets you started in using XQuery.

John



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

Default Re: Help with BDB XML Query - 11-28-2005 , 01:30 PM



On Mon, 28 Nov 2005 07:59:26 -0800, John Snelson wrote:

.... clip examples ...

Quote:
The structure of your data looks fine.

Hope this gets you started in using XQuery.

Thanks. That was a big help.



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.