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

Philippe Michiels philippe.michiels at gmail.com
Wed Nov 30 13:55:14 PST 2005


On Wednesday 30 November 2005 13:24, frederik at webinteract.nl wrote:
> 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?
Where does it say that a sequence cannot contain duplicates?
You can also eliminate duplicates by returning $seq/.

Best,
Ph



More information about the talk mailing list