[xquery-talk] Results with distinct-values varies dependent on syntax

David Carlisle davidc at nag.co.uk
Sun Nov 15 05:03:15 PST 2020


On 15/11/2020 12:32, Ihe Onwuka wrote:
> xquery version "3.1";
>
> let $schemaCollection := "/db/apps/schemas"
>  return 
> collection($schemaCollection)/xs:schema/distinct-values(@targetNamespace)
>
> does not eliminate duplicates
>
> xquery version "3.1";
>
> let $schemaCollection := "/db/apps/schemas"
>  return collection($schemaCollection)/xs:schema/@targetNamespace => 
> distinct-values()
>
> does.
>
> I checked this in Saxon and exist-db XQuery, both return the same 
> results so this may be how it's supposed to work but I don't get it.
>
>
>
> _______________________________________________
> talk at x-query.com
> http://x-query.com/mailman/listinfo/talk

distinct-values(@targetNamespace)


returns the input sequence with duplicates (by value) removed but 
@targetNamespace only selects at most one attribute so distinct-values 
will do nothing.

$schemaCollection)/xs:schema/@targetNamespace => distinct-values()

or

distinct-values($schemaCollection)/xs:schema/@targetNamespace)


here you first make the sequence of all the @targetNamespace then remove 
duplicates.


David

Disclaimer

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 and malware, and may have been automatically archived by Mimecast Ltd, an innovator in Software as a Service (SaaS) for business. 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://x-query.com/pipermail/talk/attachments/20201115/9789811b/attachment.html>


More information about the talk mailing list