[xquery-talk] Grouping without Duplicates Issues

David Carlisle davidc at nag.co.uk
Mon Jan 28 21:09:59 PST 2008

again you have posted code that calls distinct-values on a sequence of
length 1. This is not a synatx error but it will never do anything

   for $book in fn:collection("xmldb:exist://db/library")//book,

so $book will (repeatedly) be bound to a _single_ book node. That is
always the case with a for clause.

   for $doc in distinct-values($book)

distinct-values($book) is given a single node so it will return a single
value, which is the string content of the entire book.

for $r at $count in $sorted_result

this is a for loop over a sequence of length 1, so $count will always be

People have already posted in this thread the idiom you need to use
distinct-values to do grouping in xquery.


The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.

This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs. 

More information about the talk mailing list