[xquery-talk] Using Union Operator without Duplicate Records

Alice Wei ajwei at indiana.edu
Sat Dec 29 14:24:17 PST 2007


Hi,

   Sorry, I should have put down the XML output I intend to have. The 
@type is only used to extract the values, so I don't need to keep the 
attribute in my code.

   This is the XML output I have now:

   <author>Gene Pidzarko</author>
   <author>Michelle Scott</author>
   <author>Michelle Scott</author>
   <author>Ravi Pherwani</author>
    <!--More Code-->

  This is the XQuery I have:

{for $file in doc("resume_2.xml")//author
let  $author := distinct-values($file[./@type='co-author' ] union
$file[./@type='Faculty'])
order by $author ascending
return  <li>{data($author)}</li>
}

  I want the entire output to order by their first names in ascending 
order, but now it is only extracting the different values from 
different sets of nodes with <author> in them to order it.

My original XML looks something like this:

<projection>
<!--More code from other nodes-->
<author type="co-author">Andrew Tawfik</author>
<author type="co-author">Chris Hosler</author>
<author type="co-author">Michelle Scott</author>
</projection>

This is what I want:

   <author>Gene Pidzarko</author>
   <author>Michelle Scott</author>
   <author>Ravi Pherwani</author>

Is this possible?

Thanks for your help.

Alice Wei
MIS 2008
School of Library and Information Science
Indiana University Bloomington
ajwei at indiana.edu
812-856-2659

Quoting Florent Georges <lists at fgeorges.org>:

> Alice Wei wrote:
>
>  Hi
>
>>    I am not sure if any one of you have tried using the union
>> operator to concatenate all the results without duplicates.
>
>  I am not sure what you want to achieve.  Could you please post an
> example of your input, as well as the corresponding expected output?
>
>  Regards,
>
> --drkm
>
>
>
>>
> _____________________________________________________________________________
> Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers
> Yahoo! Mail http://mail.yahoo.fr



More information about the talk mailing list