Hi,
for $n in (count(distinct-values(Websites/*)) + 1) return
empty(Websites/*[$n])
(Or in 3.0 using a let.)
I know, it's bad. (But maybe in a good way?)
Cheers,
Wendell
On Fri, Nov 2, 2012 at 9:30 AM, Michael Kay <mike(_at_)saxonica(_dot_)com>
wrote:
On 02/11/2012 13:01, Dimitre Novatchev wrote:
count(Websites/*) = count(distinct-values(Websites/*))
A more efficient version (for an XPath processor with weak optimizer)
of this is:
not(Websites/*[count(distinct-values(Websites/*))+1])
So, we only count up to:
count(distinct-values(Websites/*))+1
and don't need to count all children of Websites and then compare them
to the count of distinct values.
That solution is wrong because the context for child::Websites is different
inside the predicate.
In some circumstances it would work in the form
not(//Websites/*[count(distinct-values(//Websites/*))+1])
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.
Michael Kay
Saxonica
--~------------------------------------------------------------------
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>
--~--
--
Wendell Piez | http://www.wendellpiez.com
XML | XSLT | electronic publishing
Eat Your Vegetables
_____oo_________o_o___ooooo____ooooooo_^
--~------------------------------------------------------------------
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>
--~--