xsl-list
[Top] [All Lists]

Re: [xsl] Trouble using xsl:key under XSL 1.0

2007-12-13 01:22:43
That... sounds promising. As I write this I'm about to leave the house and head off to meet my co-developer and we'll give this a try. Thanks for your suggestion :)
-----

Gareth Howells
CEO, GForce Industries

gareth(_at_)gforce-industries(_dot_)co(_dot_)uk
07862725134

GForce Industries
86, Warwick Avenue,
Quorn,
Loughborough,
LEICS.
LE12 8HE
----- Original Message ----- From: "Geert Josten" <geert(_dot_)josten(_at_)daidalos(_dot_)nl>
To: <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
Sent: Thursday, December 13, 2007 8:18 AM
Subject: RE: [xsl] Trouble using xsl:key under XSL 1.0


Hi,

As far as I know xsl:key is a top-level element. But you can acchieve
what you want using something like:

<xsl:key name="playerResultLookupByWeek" match="playerResult"
use="concat(@player, '-', ../@week)" />

And using the same concat when calling this key..

Kind regards,
Geert




Drs. G.P.H. Josten
Consultant



Daidalos BV
Source of Innovation
Hoekeindsehof 1-4
2665  JZ  Bleiswijk
Tel.: +31 (0) 10 850 1200
Fax: +31 (0) 10 850 1199
www.daidalos.nl
KvK 27164984


De informatie - verzonden in of met dit emailbericht - is afkomstig van Daidalos BV en is uitsluitend bestemd voor de geadresseerde. Indien u dit bericht onbedoeld hebt ontvangen, verzoeken wij u het te verwijderen. Aan dit bericht kunnen geen rechten worden ontleend.


From: Gareth Howells 
[mailto:subscriptions(_at_)gforce-industries(_dot_)co(_dot_)uk]
Sent: donderdag 13 december 2007 9:16
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: Re: [xsl] 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 [(_at_)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(_at_)asiatype(_dot_)com>
To: <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
Sent: Thursday, December 13, 2007 3:13 AM
Subject: Re: [xsl] 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
>
>
>
>
--~------------------------------------------------------------------
> 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>
> --~--
>


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



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


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