[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Slow XSLT

Subject: Re: Slow XSLT
From: Cleyton Jordan <cleytonjordan@xxxxxxxxxxx>
Date: Fri, 7 Mar 2008 11:36:19 +0000 (GMT)
Re:  Slow XSLT
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

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Cast Your Vote

We need your help – Vote for DataDirect XML Products!

  • Best SOA or XML site

Winners and finalists announced at SOA World Conference in November.

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.