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: Michael Kay <mike@xxxxxxxxxxxx>
Date: Fri, 02 Nov 2012 15:35:19 +0000
On 02/11/2012 14:25, Dimitre Novatchev wrote:

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?

Either way it requires the optimizer to work out that

count(distinct-values(//Websites/*))+1

returns the same value for all the nodes in

//Websites/*

which means working out that (a) all the results in //Websites/* are nodes in the same document, and (b) the expression count(distinct-values(//Websites/*))+1 is dependent on the context document but not on the context item.

Saxon has been able to do that for years, but there are many XPath engines, smaller and lighter than Saxon, that don't attempt anything near this level of analysis.

Michael Kay
Saxonica

Current Thread