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

Re: Trouble using xsl:key under XSL 1.0

Subject: Re: Trouble using xsl:key under XSL 1.0
From: "Gareth Howells" <subscriptions@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 13 Dec 2007 08:15:56 -0000
Re:  Trouble using xsl:key under XSL 1.0
Interesting. It appears to work fine as it is for the first iteration. The trouble with putting the key declaration outside the template is that I would then not be able to apply the [@week=$week] predicate to the match="playerResult" which is what causes the lookup to be restricted to one of the two sets of week data. How could I get around this, other than hardcoding 2 keys, one for each week? I'd prefer not to do that because if any new weeks are added to the XML then they would not be included in the output.

Gareth

----- Original Message ----- From: "Jeff Sese" <jsese@xxxxxxxxxxxx>
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Thursday, December 13, 2007 3:13 AM
Subject: Re: Trouble using xsl:key under XSL 1.0



On 12 13, 07, at 10:56 AM, Gareth Howells wrote:

<xsl:for-each select="//results">

<xsl:variable name="week" select="@week" />

<xsl:key name="playerResultLookupByWeek" match="playerResult[../ @week=$week]" use="@player" />

Haven't checked the whole code, but an xsl:key element must be a a child of an xsl:stylesheet or xsl:transform. this is not be a valid template. Try placing it outside the template match maybe you can make your code work.



<p> Week <xsl:value-of select="substring(@week,2,1)" /> </p>

<xsl:for-each select="//teams/team">

<p>
Team <xsl:value-of select="name" /> scored a total of <xsl:value-of select="
(sum(key('playerResultLookupByWeek',//teams/team[name=current()/ name]/teamPlayers/teamPlayer)/g) * $gPoints)
+
(sum(key('playerResultLookupByWeek',//teams/team[name=current()/ name]/teamPlayers/teamPlayer)/a) * $aPoints)
+
(sum(key('playerResultLookupByWeek',//teams/team[name=current()/ name]/teamPlayers/teamPlayer)/gda) * $gdaPoints)
+
(sum(key('playerResultLookupByWeek',//teams/team[name=current()/ name]/teamPlayers/teamPlayer)/gdcs) * $gdcsPoints)
+
(sum(key('playerResultLookupByWeek',//teams/team[name=current()/ name]/teamPlayers/teamPlayer)/gdga) * $gdgaPoints)
"/> points this week


</xsl:for-each>

</xsl:for-each>

Jeferson L. Sese jsese at asiatype dot com Asiatype Incorporated Suite 114 Columbia Tower, Ortigas Ave. Greenhills, Mandaluyong City 1550 Philippines

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

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

Buy Stylus Studio Now

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-2013 All Rights Reserved.