RE: DN-FO-09: 15.1.11 fn:distinct-values

> Being able to have fn:distinct-values return the values 
> implementation-dependent provides for better performance for 
> this often performance critical operation. Thus I would be 
> strongly against mandating an order.
> 
> If you need to preserve order you have the following options:
> 
> - Write your own function that does so
> - Lobby your favorite vendor to provide the functionality
> - Lobby for the next version of XQuery/XPath to provide this 
> functionality.
> 
> In order to do any of the last two, you would need to provide 
> some compelling use cases.
> 

There is always a danger of course that users will discover that some
implementations return results in a predictable and useful order, and become
locked-in to this behavior.

There are definitely arguments both ways on this one. One approach would be
to define the order that distinct-values returns, and advise people to wrap
it in a call of unordered() if they don't depend on this order. But that's
not a perfect solution either.

XSLT users, of course, can always use for-each-group in which the ordering
is well defined.

Michael Kay

Received on Tuesday, 24 June 2003 09:13:19 UTC