|
Subject: Re: [xsl] Slow XSLT From: "Andrew Welch" <andrew.j.welch@xxxxxxxxx> Date: Fri, 7 Mar 2008 11:59:04 +0000 |
On 07/03/2008, Cleyton Jordan <cleytonjordan@xxxxxxxxxxx> wrote:
> 1 - <xsl:variable name="teams"
> select="//team[not(.=preceding::team)]"/>
>
> I know that this expression is getting a node set of
> all the unique team elements.
>
> I am confused about the "." (dot) in this expression
> and the comparisson with the preceding::team.
>
> For the first team, does the "." (dot) match the value
> of the node - 'Brazil' - and preceding::team match the
> value as well?
>
> select="//team[not('Brazil'=preceding::'Brazil')]"/>
>
> or "." and preceding::team match the wholde node?
>
> What are we comparing here the element value or the
> whole team element?
. is the string value, so 'Brazil'
The preceding axis contains all nodes before the current node in
document order, not including the current node - so for the first
<team> it would return nothing.
> 2 - Here we are inside a loop
> <xsl:template match="results">
> <xsl:for-each select="$teams">
> <xsl:variable name="this" select="."/>
>
> Again does "." match the value of each team or the
> whole team element?
. is the string value of the current node, not the element itself
> 3 - <xsl:variable name="played"
> select="count($matches[team=$this])"/>
>
> Now we are computing how many times a particular team
> has played.
>
> count($matches[team=$this])
>
> When you use this predicate [team=$this] are we
> comparing the value of the element or the team
> elements ?
the string value of elements are compared
> 4 - <xsl:variable name="won"
> select="count($matches[team[.=$this]/@score >
> team[.!=$this]/@score])"/>
>
> I know that this expression is computing the victories
> of a particular team. However, I do not understand the
> logic of the expression. We have an extra predicate:
>
> [team[.=$this]/@score
>
> Why cant we just use [team=$this]/@score ?
because the score attribute is on the team element:
$matches[team=$this]/@score
would return the score attribute of the element in $matches if the
predicate evaluated to true
$matches[team[.=$this]/@score
returns the score attribute of the team element is the predicate
evaluated to true
> 5 - <xsl:variable name="for"
> select="sum($matches/team[.=current()]/@score)"/>
>
> What does current() mean in here? Is it the same as
> the $this variable?
current() returns the node that was the context node outside of the
xpath... when you do $matches/team the context node is changed to the
team element in $matches, the current() function will return what was
context node before you changed it.
--
Andrew Welch
http://andrewjwelch.com
Kernow: http://kernowforsaxon.sf.net/
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] Slow XSLT, Cleyton Jordan | Thread | Re: [xsl] Slow XSLT, Florent Georges |
| Re: [xsl] XSL omit part of a text i, buddhi | Date | RE: [xsl] Slow XSLT, Michael Kay |
| Month |