xsl-list
[Top] [All Lists]

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

2012-11-02 09:25:47
On Fri, Nov 2, 2012 at 6:30 AM, Michael Kay <mike(_at_)saxonica(_dot_)com> 
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.

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--