[xquery-talk] Using Union Operator without Duplicate Records

Alice Wei ajwei at indiana.edu
Sat Dec 29 20:25:49 PST 2007


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

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

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

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