Re: [xsl] What does the phrase "duplicates removed" mean precisely?

Subject: Re: [xsl] What does the phrase "duplicates removed" mean precisely?
From: "Mark Wilson" <drmark@xxxxxxxxxxxxxxx>
Date: Wed, 1 Feb 2006 05:39:34 -0500
Thank you again for a very clear explaination. The last paragraph in your answer was the information I was seeking, and the difference between 1.0 and 2.0 was most helpful.

----- Original Message ----- From: "David Carlisle" <davidc@xxxxxxxxx>
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Tuesday, January 31, 2006 7:54 PM
Subject: Re: [xsl] What does the phrase "duplicates removed" mean precisely?

Note that the terminology (and the facts) changes between XSLT1 and XSLT2 and your message refered to Michael Kay's 2.0 book, and Dave P's 1.0 FAQ. So I'll give two answers, but it would probably simplify things for you if you fixed on one or other version initially.

a "node" is the generic term for all kinds of structured value in xpath,
element nodes, attribute nodes, comment nodes etc.

In XSLT1 the basic data type is a "node set" and sets by definition
never have duplicates, so if you look at sets of integers, the set
{1,3,1,1} is the same as the set {1,3} and has two members.
Similarly in Xpath node sets if you (say) select the union of all the
attributes, and one specific attribute
select="@*|@this" then this is the same as just selecting all attributes
select="@*" yiu don't get the attribute this="that" twice, just as the
set {1,3,1,1} only has  member equal to 1.

In Xpath2 th ebasic data type is no longer a set but a sequence (that is
an ordered lists) and if we again look at lists of integers  the
(1,3) and (1,3,1,1) are different, one has length 2, and one has length
4,with 1 appearing threee times.

given <foo this="that" a="b" c="d"/>

so @*|@this again only contains the this="that" attribute once, although
in xpath2 (unlike xpath1) you have the possibilty of having a sequence
where it appears twice, for example select="@*,@this"

Are there any other kind of "duplicates" removed?

Note that it is duplicates by _identity_ not by value. Given <x> <y>a</y> <y>a</y> </x>

if the current node is x then select="y" will select both y element
nodes, th efact that they have the same content doesn't make them
duplicates. However of you select the same element twice for example
select="y[last()]|y[2]" selects the second one twice in this case
then this dupication is rempved and the result is a node set (in xpath1)
or sequence (in xpath2) with just one y element.


________________________________________________________________________ This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: ________________________________________________________________________

Current Thread