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

Grouping without Duplicates Issues

Wei, Alice J. ajwei at indiana.edu
Mon Jan 28 15:27:18 PST 2008


  Grouping without Duplicates Issues
Hi,

  I am trying to parse through a group of files through fn:collection, but I am not sure if grouped results would display wrong numbers of results after using distinct-values() because white space is taken into consideration.
  Here is my XQuery:

<booklist>
{
for $book in fn:collection("xmldb:exist://db/library")//book,
$title in $book/title,
$para in $book/p,
$note in $book/note
let $sorted_result:=
for $doc in distinct-values($book)
where distinct-values(contains($para,'hey') or contains($note,'hey'))
order by $title ascending, $para ascending
return $doc
for $r at $count in $sorted_result
let $nodes := $book[. = $r]
return
<book>
<statistics>
Showing Result: {$count} / {count($sorted_result)}
</statistics>
{$title}
{$para}
{$note}
</book>
}
</booklist>

  The odd thing is that when I run the search, it appears that it still gives me back 2 of every single result that match the query, and it also gives me 1 for every number no matter how many the total is.
  For example:

<booklist>
<book>
<statistics> Showing Result: 1 / 1</statistics>
<title type ="main"> Xquery from the Experts: <emph rend="bold">A Guide to the W3c XML Query Language</emph></head>
<p>The individual perspectives on the concepts behind the XQuery language offered by "XQuery from the Experts "will be of great value to those who
are seeking to understand the implications, opportunities, and challenges of XQuery as they design future information systems based on XML.</p>
<note>Published 2004 by Addison-Wesley</note>
</book>
<book>
<statistics> Showing Result: 1 / 1</statistics>
<title type ="main"> Xquery from the Experts: <emph rend="bold">A Guide to the W3c XML Query Language</emph></head>
<p>The individual perspectives on the concepts behind the XQuery language offered by "XQuery from the Experts "will be of great value to those who
are seeking to understand the implications, opportunities, and challenges of XQuery as they design future information systems based on XML.</p>
<note>Published 2004 by Addison-Wesley</note>
</book>
</booklist>

My desired output:

<booklist>
<book>
<statistics> Showing Result: 1 / 1</statistics>
<title type ="main"> Xquery from the Experts: <emph rend="bold">A Guide to the W3c XML Query Language</emph></head>
<p>The individual perspectives on the concepts behind the XQuery language offered by "XQuery from the Experts "will be of great value to those who
are seeking to understand the implications, opportunities, and challenges of XQuery as they design future information systems based on XML.</p>
<note>Published 2004 by Addison-Wesley</note>
</book>
</booklist>

Does the distinct-values() supposed to be doing something else here?
Another question is, if I did were not mistaken, does not the structure of the XQuery be similar to both doc() and collection() according to XPath 2.0?

Thanks to those who can help.
======================================================
Alice Wei
MIS 2008
School of Library and Information Science
Indiana University Bloomington
http://x-query.com/mailman/listinfo/talk



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.