[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message]

Incorrect Intersect and Except Output?

Wei, Alice J. ajwei at indiana.edu
Sat Mar 29 07:33:58 PST 2008


  Incorrect Intersect and Except Output?
Hi, XQueriers:

  I think I am still having quite a bit of issues with this particular XPath expression.

  I have used the idea Jonathan Robie brought up last time by combining the expressions by calling the original variables

let $a := collection("xmldb:exist://db/cbm")//ad//address[contains(upper-case(.),$search)],
$c := collection("xmldb:exist://db/cbm")//ad//address[contains(upper-case(.),$search2)],

 if (($search ne "") and ($search4 eq "address") and ($search5 eq "address") and ($search2  ne "") and ($search7 eq "and") and ($search3 eq ""))
then  <div>{local:count-distinct-values($a intersect $c)}
</div>

I attempted to have this bring out only the items that contain the word $search and $search2 in the address tag, but it appears that it always brings one of the words back, and not just the result that contains both words. I tried switching the clause to $a except $c, but the result is always problematic.

I used what Jonathan showed me last time by writing this little snippet to try how intersect and except works:

let $a := <a><b>1</b><b>2</b><b>3</b></a>,
$b := <c><b>What</b><b>2</b><b>3</b><b>4</b></c>,
return
<foo>{$a except $b}</foo>

brings

<foo>
<a>
<b>1</b>
<b>2</b>
<b>3</b>
</a>
</foo>

If I use $a intersect $b, it brings me an empty node <foo/>
Isn't intersect supposed to bring back what is contained in $b and $a?

As for except, since it supposed to bring only what is not co-shared between $a and $b, (according to the original concept in SQL), isn't it supposed to bring back

<foo>
<a>
<b>1</b>
<b>What</b>
<b>4</b>
</a>
</foo>

Am I missing something here?

Thanks for your help.

Alice
======================================================
Alice Wei
MIS 2008
School of Library and Information Science
Indiana University Bloomington
http://x-query.com/mailman/listinfo/talk



Purchase Stylus Studio Online Today!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.