xsl-list
[Top] [All Lists]

Re: [xsl] finding out distinct node/values

2010-02-10 11:35:04
And, please, hit me over the head: where is the second (hidden?) loop
that would make this O(n^2)?

Here:

   <xsl:for-each select="/table/rows/row/name">
     <xsl:if test="not(. = preceding::name)">

If that is

test=". = key(....)[1]"

then for every n you are doing 1 comparison.

If you use the preceding axis:

test="not(. = preceding::name)"

then for every n, you are doing n comparisons (well n - 1) so thats
where the n^2 comes from.

I guess it might be more apparent if written like this:

<xsl:for-each select="/table/rows/row/name">
  <xsl:for-each select="preceding::name">
    <!-- do comparison -->


cheers
-- 
Andrew Welch
http://andrewjwelch.com
Kernow: http://kernowforsaxon.sf.net/

--~------------------------------------------------------------------
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>
--~--