[xquery-talk] Incorrect Intersect and Except Output?

Wei, Alice J. ajwei at indiana.edu
Sun Mar 30 19:09:00 PST 2008

Hi, Jonathan:

  I think I understand what you mean by having different nodes in the both sets I have indicated. However, since <b>2</b><b>3</b> are co-shared between the two sets, this means that I have to go around by doing something like

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>
<foo>{(($a/b union $b/b) except ($a/b except $b/b))}</foo>



This is not exactly what I desired, but are you saying that I have to use union joins and combine it with other operators for the output? And, how can I get rid of the <b>2</b><b>3</b> and switch it with <b>1</b>?

Thanks for your help.

Alice Wei
MIS 2008
School of Library and Information Science
Indiana University Bloomington
ajwei at indiana.edu
From: Jonathan Robie [jonathan.robie at redhat.com]
Sent: Sunday, March 30, 2008 1:45 PM
To: Wei, Alice J.
Cc: talk at x-query.com
Subject: Re: [xquery-talk] Incorrect Intersect and Except Output?

Wei, Alice J. wrote:
> 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>

Except tests for node identity (you seem to expect it to test the node
values). If none of the nodes in $a are also in $b, then $a except $b is
the same as $a.

> 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?

Yes, but there are no nodes in $b that are also in $a, and vice versa.


More information about the talk mailing list