[xquery-talk] Remove "duplicates" from a sequence

Priscilla Walmsley pwalmsley-lists at datypic.com
Wed Nov 30 08:10:14 PST 2005


Hi,

The "intersect" operator is supposed to remove duplicates, so Saxon and
Galax are correct.  You could also use "$seq/.", which sets up a path
expression, which also removes duplicates.

Hope that helps,
Priscilla

----------------------------------------------------------------- 
Priscilla Walmsley                 http://www.datypic.com 
Author, Definitive XML Schema     (Prentice Hall PTR) 
        Definitive XQuery (coming in 2006)
-----------------------------------------------------------------
 

> -----Original Message-----
> From: talk-bounces at xquery.com 
> [mailto:talk-bounces at xquery.com] On Behalf Of frederik at webinteract.nl
> Sent: Wednesday, November 30, 2005 7:25 AM
> To: talk at xquery.com
> Subject: [xquery-talk] Remove "duplicates" from a sequence
> 
> Given the following example in XQuery:
> 
> let $root := element root{}
> return
> 	let $seq :=
> 		for $i in (1, 2)
> 		return $root
> 	return $seq
> 
> This will return a sequence <root/><root/>.
> I would like the output to be only <root/> (so with no "duplicates").
> 
> In Saxon (and Galax) this can be done with the following query:
> let $root := element root{}
> return
> 	let $seq :=
> 		for $i in (1, 2)
> 		return $root
> 	return $seq intersect $seq
> 
> However, how can this be correct since a sequence can not 
> contain duplicates?
> 
> For the record, the Altova XQuery processor does return 
> <root/><root/>.
> 
> 
> Kind regards,
> Frederik & Tom.
> 
> _______________________________________________
> talk at xquery.com
> http://xquery.com/mailman/listinfo/talk
> 



More information about the talk mailing list