Forum Moderators: open

Message Too Old, No Replies

XSL Keys - Possible to match an attribute?

         

dcampbell

12:20 pm on Dec 8, 2005 (gmt 0)

10+ Year Member



Hi folks

I have an XML feed I'm receiving from another party which contains a list of premiership teams at the top of the document with an assigned id, for example :
<Teams>
<Team id="2" name="Aston Villa" />
<Team id="3" name="Charlton" />
<Team id="4" name="Chelsea" />
...
</Teams>

The Team id's are then referenced throughout the document in relation to fixtures, i.e. 2 v 3.

To reference the teams I'm trying to use a key, however I'm having trouble trying to match the key on an attribute. I've tried numerous variations of the following but none seem to work:

<xsl:key name="teamlist" match="Team/@name" use="Team/@id"/>

If the xml feed was as follows:

<Teams>
<Team id="2">Aston Villa</Team>
<Team id="3">Charlton</Team>
<Team id="4">Chelsea</Team>
</Teams>

Then the following key works fine :

<xsl:key name="teamlist" match="Team" use="@id"/>

However, this is not the case and as the XML feed is generic it can't be amended.

So, in a nutshell my question is, 'is it possible to use an attribute as the pattern match element of a key' and if so how?

Thanks

dcampbell

2:56 pm on Dec 9, 2005 (gmt 0)

10+ Year Member



Irony strikes, I try to do this for 3 days without success, post here and within an hour I resolved the issue.

Thanks