[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message]

Using Union Operator without Duplicate Records

Florent Georges lists at fgeorges.org
Sat Dec 29 20:53:54 PST 2007


  Using Union Operator without Duplicate Records
Alice Wei wrote:

> {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>
> }

  Actually the distinct-values() is in the for body.  So it is called
with a sequence of 0 or 1 item each time.  Try something like the
following instead (the distinct-values() is used here to give the right
sequence to the for):

    for $a in
      <projection>
         <author type="co-author">Andrew Tawfik</author>
         <author type="co-author">Chris Hosler</author>
         <author type="co-author">Michelle Scott</author>
         <author type="Faculty">Michelle Scott</author>
      </projection>
      / distinct-values(.//author[@type = ('co-author', 'Faculty')])
    order by $a ascending return
    <li> {
      data($a)
    }
    </li>

  Result:

    <?xml version="1.0" encoding="UTF-8"?>
    <li>Andrew Tawfik</li>
    <li>Chris Hosler</li>
    <li>Michelle Scott</li>

  Regards,

--drkm






















      _____________________________________________________________________________ 
Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! Mail http://mail.yahoo.fr



Purchase Stylus Studio Online Today!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.