Given the following xml document...
<ws>
<series year="2005" mvp="Jermaine Dye">
<team name="Chicago White Sox" wins="4" />
<team name="Houston Astros" wins="0" />
</series>
<series year="2004" mvp="Manny Ramirez">
<team name="Boston Red Sox" wins="4" />
<team name="St. Louis Cardinals" wins="0" />
</series>
</ws>
I have created a key to get the name attribute of the first team in each series, and I am trying to loop through and list out each name for each series as follows; I am currently not returning any results and am not sure what is wrong with my value-of reference?...
<xsl:key name="winners" match="team[1]" use="@name" />
<xsl:template match="/">
<xsl:for-each select="ws/series">
<xsl:value-of select="key('winners', @name)" />
</xsl:for-each>
</xsl:template>
Expected output would be...
Chicago White Sox (the first team from series 1)
Boston Red Sox (the first team from series 2)
The xml data I have provided only includes 2 series elements when in actuality there are hundred's. The key is used to speed up the transformation process and works along with other keys to generate my result document.