[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] [Summary] Three ways to express in XPath that there are no duplicates in a list of items


Subject: Re: [xsl] [Summary] Three ways to express in XPath that there are no duplicates in a list of items
From: Dimitre Novatchev <dnovatchev@xxxxxxxxx>
Date: Fri, 2 Nov 2012 07:25:12 -0700

On Fri, Nov 2, 2012 at 6:30 AM, Michael Kay <mike@xxxxxxxxxxxx> wrote:
> In some circumstances it would work in the form
>
> not(//Websites/*[count(distinct-values(//Websites/*))+1])

Yes, this is what I meant -- thank's for the correction.

>
> But that solution is more dependent on a smart optimizer than the original,
> because a naive engine will reevaluate the predicate once for every node
> selected; and the performance of an unoptimized implementation of the
> original is still (almost) linear, whereas an unoptimized implementation of
> the latter is quadratic.

I believe that it we re-write this in a more specific form then it
wouldn't be so optimizer specific:

  not(//Websites/*[position() = count(distinct-values(//Websites/*))+1])

or does this require the same degree of cleverness than the previous
expression does?

Or probably this is even more specific:

  not(//Websites/*[position() gt count(distinct-values(//Websites/*))])



-- 
Cheers,
Dimitre Novatchev
---------------------------------------
Truly great madness cannot be achieved without significant intelligence.
---------------------------------------
To invent, you need a good imagination and a pile of junk
-------------------------------------
Never fight an inanimate object
-------------------------------------
To avoid situations in which you might make mistakes may be the
biggest mistake of all
------------------------------------
Quality means doing it right when no one is looking.
-------------------------------------
You've achieved success in your field when you don't know whether what
you're doing is work or play
-------------------------------------
Facts do not cease to exist because they are ignored.
-------------------------------------
Typing monkeys will write all Shakespeare's works in 200yrs.Will they
write all patents, too? :)
-------------------------------------
I finally figured out the only reason to be alive is to enjoy it.


Current Thread