Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xsl] Slow XSLT

From: "Andrew Welch" <andrew.j.welch@--------->
To:
Date: 3/7/2008 11:59:00 AM
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/


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent