xsl-list
[Top] [All Lists]

Re: [xsl] Relationships in for-each statement

2006-09-08 08:57:39

  Well, trying this, I find a problem in that my expression

  <xsl:for-each select="//program[tv:title = $matcher]/@id">

  isn't really in that form.


<xsl:for-each select="//program[tv:title = $matcher]/@id">

is

<xsl:key name="x" match="program" use="tv:title"/>

...
<xsl:for-each select="key('x',$matcher)/@xid">


but as I say if you only have //program[tv:title=something] once in the
stylesheet then you have to take the hit of searching the document at
least once so a key may not help(I just say this so implementors of
smart optimisers can jump in and say that they make this a false
statement:-) the key only wins if you do the search more than once. it
wins big time and can make orders of magnitute speedup if you are doing
this

<xsl:for-each select="//program[tv:title =
$matcher][following-sibling::program[tv:title=something]]/@id">

as then changing to a key can change an n-squared algroithm to an n or
less) algorithm and if you've a 100 programs 10000 is a lot less than
100:-) This is why "muenchian grouping" (ie using keys for grouping
problems made such a big impact on xslt 1 usage, as typically not only
did you have to seach down to find all the items you searched across (or
down again, which is worse) to find all the ones in the same group.

David



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