xsl-list
[Top] [All Lists]

Re: [xsl] Slow XSLT

2008-03-07 04:36:44
Hi,

--- Manfred Staudinger <manfred(_dot_)staudinger(_at_)gmail(_dot_)com>
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

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

<Prev in Thread] Current Thread [Next in Thread>