home contribute faq download

FunctX XQuery Functions

functx:value-intersect

The intersection of two sequences of values

Google
Webdatypic.com

Description

The functx:value-intersect function returns the intersection of the values in two sequences (values that appear in both sequences) in an implementation-defined order. It removes duplicates. This function is useful because the built-in intersect operator only works on nodes, not atomic values.

Arguments and Return Type

NameTypeDescription
$arg1 xs:anyAtomicType* the first sequence
$arg2 xs:anyAtomicType* the second sequence
return value xs:anyAtomicType*

XQuery Function Declaration

See XSLT definition.
declare namespace functx = "http://www.functx.com";
declare function functx:value-intersect
  ( $arg1 as xs:anyAtomicType* ,
    $arg2 as xs:anyAtomicType* )  as xs:anyAtomicType* {

  distinct-values($arg1[.=$arg2])
 } ;

Examples

XQuery ExampleResults
functx:value-intersect((1,2),(2,3))
2
functx:value-intersect((1,2,3),(2,3,4))
(2, 3)
functx:value-intersect((1,2,2,3),(2,3))
(2, 3)
functx:value-intersect((1,2,2,3),())
()

See Also

functx:value-unionThe union of two sequences of values
functx:value-exceptThe values in one sequence that aren't in another sequence

History

Published OnLast UpdatedContributor(s)
2006-06-272007-02-26W3C XML Query Working Group, XQuery 1.0 and XPath 2.0 Functions and Operators, http://www.w3.org/TR/xpath-functions/
Datypic XQuery Services

Recommended Reading:

XQuery