给定以下 xml 文档...
<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>
我创建了一个键来获取每个系列中第一支球队的名称属性,并且我正在尝试循环并列出每个系列的每个名称,如下所示;我目前没有返回任何结果,也不确定我的参考价值有什么问题?...
<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>
预期输出将是...
Chicago White Sox (the first team from series 1)
Boston Red Sox (the first team from series 2)
我提供的 xml 数据仅包含 2 个系列元素,而实际上有数百个。该密钥用于加快转换过程,并与其他密钥一起生成我的结果文档。