home contribute faq download

FunctX XQuery Functions

functx:non-distinct-values

Returns any values that appear more than once in a sequence

Google
Webxqueryfunctions.com

Description

The functx:non-distinct-values function returns any values that appear more than once in a list, based on typed value. All the values must have comparable types, or be untyped.

Arguments and Return Type

NameTypeDescription
$seq xs:anyAtomicType* the sequence of values
return value xs:anyAtomicType*

XQuery Function Declaration

See XSLT definition.
XQuery Syntax for January 2007 (1.0):
declare namespace functx = "http://www.functx.com"; 
declare function functx:non-distinct-values 
  ( $seq as xs:anyAtomicType* )  as xs:anyAtomicType* {
       
   for $val in distinct-values($seq)
   return $val[count($seq[. = $val]) > 1]
 } ;
XQuery Syntax for July 2004 - November 2005 (CR):
declare namespace functx = "http://www.functx.com"; 
declare function functx:non-distinct-values 
  ( $seq as xdt:anyAtomicType* )  as xdt:anyAtomicType* {
       
   for $val in distinct-values($seq)
   return $val[count($seq[. = $val]) > 1]
 } ;
XQuery Syntax for May 2003:
declare namespace functx = "http://www.functx.com" 
define function non-distinct-values 
  ( $seq as xdt:anyAtomicType* )  as xdt:anyAtomicType* {
       
   for $val in fn:distinct-values($seq)
   return $val[fn:count($seq[. = $val]) > 1]
 }

Examples

XQuery ExampleResults
functx:non-distinct-values( (1,2,1,3))
1
functx:non-distinct-values( (1,2,1,3,2.0))
(1, 2)
functx:non-distinct-values( (1,2,3) )
()

See Also

functx:are-distinct-valuesWhether all the values in a sequence are distinct
fn:distinct-valuesThe distinct atomic values in a sequence

History

Published OnLast UpdatedContributor(s)
2006-06-272007-02-26Priscilla Walmsley, Datypic, pwalmsley@datypic.com, http://www.datypic.com
Need XQuery Help?
D A T Y P I C
Training | Consulting | Development

XQuery by Priscilla WalmsleyGet the book!
XQuery by Priscilla Walmsley