了解XML和XSLT但仍然在摔跤。我还在保龄球联盟网站上工作,我需要用一个标题显示多个数据...
这是代码,你会明白我的意思:
<TeamScores>
<TeamScore>
<Name><![CDATA[AWW 2]]></Name>
<PlayerScores>
<PlayerScore>
<Name>Dhr. Foubert Guy</Name>
<HDC>21</HDC>
<HighSerie>599</HighSerie>
<HighGame>236</HighGame>
</PlayerScore>
<PlayerScore>
<Name>Dhr. Goris Swa</Name>
<HDC>28</HDC>
<HighSerie>545</HighSerie>
<HighGame>233</HighGame>
</PlayerScore>
<PlayerScore>
<Name>Dhr. Korsten Ronny</Name>
<HDC>7</HDC>
<HighSerie>626</HighSerie>
<HighGame>219</HighGame>
</PlayerScore>
<PlayerScore>
<Name>Dhr. Kortsen David</Name>
<HDC>23</HDC>
<HighSerie>499</HighSerie>
<HighGame>183</HighGame>
</PlayerScore>
<PlayerScore>
<Name>Dhr. Pauwels Jan</Name>
<HDC>26</HDC>
<HighSerie>538</HighSerie>
<HighGame>204</HighGame>
</PlayerScore>
<PlayerScore>
<Name>Mvr. Van Steenwinkel Sandra</Name>
<HDC>44</HDC>
<HighSerie>449</HighSerie>
<HighGame>171</HighGame>
</PlayerScore>
</PlayerScores>
</TeamScore>
<TeamScore>
<Name><![CDATA[De Candy Pins]]></Name>
<PlayerScores>
<PlayerScore>
<Name>Dhr. Brusselmans Steven</Name>
<Game1>156</Game1>
<Game2>157</Game2>
<Game3>147</Game3>
<Tot>460</Tot>
<TotHDC>544</TotHDC>
<HDC>28</HDC>
<HighSerie>533</HighSerie>
<HighGame>204</HighGame>
</PlayerScore>
<PlayerScore>
<Name>Mvr. Claes Ginne</Name>
<HDC>61</HDC>
<HighSerie>358</HighSerie>
<HighGame>149</HighGame>
</PlayerScore>
<PlayerScore>
<Name>Dhr. Jurgen Driesen</Name>
<Game1>179</Game1>
<Game2>214</Game2>
<Game3>171</Game3>
<Tot>564</Tot>
<TotHDC>564</TotHDC>
<HDC>0</HDC>
<HighSerie>749</HighSerie>
<HighGame>269</HighGame>
</PlayerScore>
<PlayerScore>
<Name>Mvr. Kelders Wanda</Name>
<HDC>42</HDC>
<HighSerie>521</HighSerie>
<HighGame>207</HighGame>
</PlayerScore>
<PlayerScore>
<Name>Dhr. Schrovens Bart</Name>
<HDC>22</HDC>
<HighSerie>519</HighSerie>
<HighGame>210</HighGame>
</PlayerScore>
<PlayerScore>
<Name>Dhr. Tielemans Steven</Name>
<Game1>154</Game1>
<Game2>197</Game2>
<Game3>235</Game3>
<Tot>586</Tot>
<TotHDC>595</TotHDC>
<HDC>3</HDC>
<HighSerie>671</HighSerie>
<HighGame>242</HighGame>
</PlayerScore>
<PlayerScore>
<Name>Mvr. Van Reeth Natasja</Name>
<HDC>52</HDC>
<HighSerie>363</HighSerie>
<HighGame>129</HighGame>
</PlayerScore>
<PlayerScore>
<Name>Dhr. Weijten Jeroen</Name>
<HDC>7</HDC>
<HighSerie>642</HighSerie>
<HighGame>232</HighGame>
</PlayerScore>
</PlayerScores>
<Game1>489</Game1>
<Game2>568</Game2>
<Game3>553</Game3>
<Tot>1610</Tot>
<TotHDC>1703</TotHDC>
</TeamScore>
<TeamScore>
我设法将所有玩家的分数显示在一张桌子上......但是我还想展示他们为之效力的球队
这是我正在使用的XSLT:
<xsl:template match="/leagueScores/TeamScores">
<html>
<body>
<h1>Individuele Uitslagen</h1>
<table border="1">
<tr>
<th>Naam</th>
<th>G1</th>
<th>G2</th>
<th>G3</th>
<th>TOT S</th>
<th>TOT H</th>
<th>HDC</th>
<th>Hi Serie</th>
<th>Hi Game</th>
</tr>
<xsl:for-each select="TeamScore/PlayerScores/PlayerScore">
<xsl:if test="Game1 > 0">
<tr>
<td><xsl:value-of select="Name"/></td>
<td><xsl:value-of select="Game1"/></td>
<td><xsl:value-of select="Game2"/></td>
<td><xsl:value-of select="Game3"/></td>
<td><xsl:value-of select="Tot"/></td>
<td><xsl:value-of select="TotHDC"/></td>
<td><xsl:value-of select="HDC"/></td>
<td><xsl:value-of select="HighSerie"/></td>
<td><xsl:value-of select="HighGame"/></td>
</tr>
</xsl:if>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
我正在寻找这样的输出:
"TEAM1"
"PLAYER1"
"PLAYER2"
"PLAYER3"
"TEAM2"
"PLAYER1"
"PLAYER2"
"PLAYER3"
...在一个包含游戏和总计列的表中... 所以我只想在正确的球队球员之间为每支球队插入一排。
这可能吗?
答案 0 :(得分:0)
答案 1 :(得分:0)
而不是一次性使用for-each
个PlayerScore
元素,而是使用两个嵌套级别来接近它
<xsl:for-each select="TeamScore">
<tr>
<td colspan="9">
<xsl:value-of select="Name"/>
</td>
</tr>
<xsl:for-each select="PlayerScores/PlayerScore">
<!-- ... -->