Is there a way to select the top two and also anything that ties?
For example if you were looking through stats and you had games that had a scores of 8,6,6,4,3 but i only wanna use the value of the top 2 unless there is a tie so in this case i want to display 8,6,6 but if the scores were 8,6,5,4,3 i would only want to display 8,6.
So now for the first team i wanna show theree highest two scores but there happens to be a tie betweens the two games where they scored 6 . So in this case i need to show them both in my list. In the other game i would just show 8 and 6 because there the top two.
The html would then look like this
top 2 scores 8 vs teamblue 6 vs team red 6 vs team green
I think you could still use the key part I posted above to select unique scores, then as you are writing out each score check for any duplicates
<xsl:if test="count(schedule/game [score = current()/score]) > 0"> <!-- there is a tie, select all with the same score, except the current --> <xsl:for-each select="schedule/game [score = current()/score][position() > 1"> ...info about the tied game... </xsl:for-each> </xsl:if>
Is there a way to select the top two and also anything that ties?
For example if you were looking through stats and you had games that had a scores of 8,6,6,4,3 but i only wanna use the value of the top 2 unless there is a tie so in this case i want to display 8,6,6 but if the scores were 8,6,5,4,3 i would only want to display 8,6.
This is what i already have I only need help with figuring out the tie part please and thankyou.
For the tie part, you could try using XSLT keys to only select unique stats values.
Above your <xsl:template>
Then adjust your for-each loop
That way in your example, you would only get 8,6 instead of 8,6,6.
Would that work?
-Tom
Oh sorry my question was a little confusing but in my case i want to show 8,6,6 if there is two 6's
Here are two examples of the xml for a season of games in any sport for two different teams
So now for the first team i wanna show theree highest two scores but there happens to be a tie betweens the two games where they scored 6 . So in this case i need to show them both in my list. In the other game i would just show 8 and 6 because there the top two.
The html would then look like this
I think you could still use the key part I posted above to select unique scores, then as you are writing out each score check for any duplicates
<xsl:if test="count(schedule/game [score = current()/score]) > 0">
<!-- there is a tie, select all with the same score, except the current -->
<xsl:for-each select="schedule/game [score = current()/score][position() > 1">
...info about the tied game...
</xsl:for-each>
</xsl:if>
yea that works Thanks a lot I appreciate it
is working on a reply...