Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

XQuery question  RSS feed

Kevinnnn Regan
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!