File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes XML and Related Technologies and the fly likes XQuery question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "XQuery question " Watch "XQuery question " New topic

XQuery question

Kevinnnn Regan

Joined: Jun 16, 2006
Posts: 1
Hi, I'm new to Xquery and have a question.

Say I have two datasets each listing people. The two datasets may overlap i.e. a particular person may exist in each one... how do I generate a list of distinct people i.e. a list containing each unique person in the union of the two sets?

I have this:

declare function tns:getPeople() as element(ns0 ersonSummary)* {

let $people := ns1:IBIS() union ns3:TECS()
for $last in distinct-values($people/LNAME),
$first in distinct-values($people[LNAME=$last]/FNAME)
for $person in $people
where ($person/LNAME = $last and $person/FNAME = $first)
<ns0 ersonSummary>
<ns0:SSN>{fn ata($person/SID)}</ns0:SSN>
<ns0:FirstName>{fn ata($person/FNAME)}</ns0:FirstName>
<ns0:LastName>{fn ata($person/LNAME)}</ns0:LastName>
</ns0 ersonSummary>


but it doesn't work... there is a duplicate in the resulting list - the 2nd for loop just searches for each individual at a time - in the case of the duplicate it just creates a summary for him twice.

Note that I'm using BEA Aqualogic Data Services Platform (I have never used xquery before this) so if some of this stuff looks non-standard that's probably why.

Can anybody help me out or point me to somewhere/one that can?

Thanks a lot!

I agree. Here's the link:
subject: XQuery question
It's not a secret anymore!