Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xsl] Slow XSLT

From: Cleyton Jordan <cleytonjordan@----------->
To:
Date: 3/7/2008 11:37:00 AM
Hi,

--- Manfred Staudinger <manfred.staudinger@xxxxxxxxx>
wrote:
> - see Michael Kay:
>   
>
http://www.ibm.com/developerworks/xml/library/x-xslt/
> Manfred

I am reading one of the articles that Manfred has
suggested (Michael Kay: What kind of language is
XSLT?) so that I can learn more about using node sets,
apply templates and recursion but I do not fully
understand some of the XPATH expressions.

I would appreciate your help in understanding the
expressions below:

Given this XML (as per the Michael Kay's article):
________________


<results group="A">
<match>
    <date>10-Jun-1998</date>
    <team score="2">Brazil</team>
    <team score="1">Scotland</team>
</match>
<match>
    <date>10-Jun-1998</date>
    <team score="2">Morocco</team>
    <team score="2">Norway</team>
</match>
<match>
    <date>23-Jun-1998</date>
    <team score="1">Brazil</team>
    <team score="2">Norway</team>
</match>
</results>


These are the expressions used to compute the teams
standings:

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?

+++++++

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?


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 ? 

4 - <xsl:variable name="won"
select="count($matches[team[.=$this]/@score &gt;
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 ?


+++++++++++++++

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? 

In this case we are not using a predicate for the
$matches variable. why? 

$matches/team

$matches/team[.=current()]/@score)


Thanks for you help.

Cheers

C 




		
___________________________________________________________ 
To help you stay safe and secure online, we've developed the all new Yahoo! Security Centre. http://uk.security.yahoo.com


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