home contribute faq download

FunctX XQuery Functions

functx:value-except

The values in one sequence that aren't in another sequence

Google
Webxqueryfunctions.com

Description

The functx:value-except function returns the values in one sequence that do not appear in the second sequence, in an implementation-defined order. It removes duplicates, even among the values that appear only in the first sequence. This function is useful because the built-in except 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.
XQuery Syntax for January 2007 (1.0):
declare namespace functx = "http://www.functx.com"; 
declare function functx:value-except 
  ( $arg1 as xs:anyAtomicType* ,
    $arg2 as xs:anyAtomicType* )  as xs:anyAtomicType* {
       
  distinct-values($arg1[not(.=$arg2)])
 } ;
XQuery Syntax for July 2004 - November 2005 (CR):
declare namespace functx = "http://www.functx.com"; 
declare function functx:value-except 
  ( $arg1 as xdt:anyAtomicType* ,
    $arg2 as xdt:anyAtomicType* )  as xdt:anyAtomicType* {
       
  distinct-values($arg1[not(.=$arg2)])
 } ;
XQuery Syntax for May 2003:
declare namespace functx = "http://www.functx.com" 
define function value-except 
  ( $arg1 as xdt:anyAtomicType* ,
    $arg2 as xdt:anyAtomicType* )  as xdt:anyAtomicType* {
       
  fn:distinct-values($arg1[fn:not(.=$arg2)])
 }

Examples

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

See Also

functx:value-unionThe union of two sequences of values
functx:value-intersectThe intersection of two sequences of values

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/
Need XQuery Help?
D A T Y P I C
Training | Consulting | Development

XQuery by Priscilla WalmsleyGet the book!
XQuery by Priscilla Walmsley