|
From: <rga...@us...> - 2002-10-28 13:54:26
|
Update of /cvsroot/csms/csms-core/src/resources/conf
In directory usw-pr-cvs1:/tmp/cvs-serv32558
Added Files:
Scores2HTML.xsl ScoringConfig.xsl footballEvents.xml
players.xml
Log Message:
Added initial configuration files for Fanfoot fantasy football
--- NEW FILE: Scores2HTML.xsl ---
<?xml version="1.0" encoding="UTF-8" ?>
<!--
Document : Scores2HTML.xsl
Created on : 24 September 2002, 18:20
Author : rgardler
Description:
Transforms a scores XML document into HTML
-->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text/html"/>
<!-- Create the keys for the players -->
<xsl:key name="players" match = "/scores/player" use="@name"/>
<!-- template rule matching source root element -->
<xsl:template match="/">
<html>
<body>
<h1>Fanfoot Scores</h1>
<table>
<xsl:apply-templates select="scores/player[generate-id()=generate-id(key('players',@name))]/@name"
mode="summary"/>
</table>
<br/>
<table>
<tr><th>Errors</th></tr>
<xsl:apply-templates select="scores/error"/>
</table>
<br/>
<xsl:apply-templates select="scores/player[generate-id()=generate-id(key('players',@name))]/@name"
mode="detail"/>
</body>
</html>
</xsl:template>
<xsl:template match="@name" mode="summary">
<xsl:variable name="name"><xsl:value-of select="."/></xsl:variable>
<tr>
<td><xsl:value-of select="."/></td>
<td><xsl:value-of select="sum(/scores/player[@name=$name]/points)"/></td>
</tr>
</xsl:template>
<xsl:template match="@name" mode="detail">
<xsl:variable name="name"><xsl:value-of select="."/></xsl:variable>
<table>
<tr>
<th colspan='2'><xsl:value-of select="."/></th>
</tr>
<xsl:apply-templates select="key('players',.)" mode="detail"/>
<tr>
<th>Total</th>
<th>
<xsl:value-of select="sum(/scores/player[@name=$name]/points)"/>
</th>
</tr>
</table>
</xsl:template>
<xsl:template match="player" mode="detail">
<tr>
<td><xsl:value-of select="event/type"/></td>
<td><xsl:value-of select="points"/></td>
</tr>
</xsl:template>
<xsl:template match="error">
<tr>
<td><xsl:value-of select="."/></td>
</tr>
</xsl:template>
</xsl:stylesheet>
--- NEW FILE: ScoringConfig.xsl ---
<?xml version="1.0" encoding="UTF-8" ?>
<!--
Document : BBCScoringConfigURL.xsl
Created on : 24 September 2002, 14:07
Author : rgardler
Description:
Transforms an Events XML document into a score XML document
-->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:output method="text/xml"/>
<!-- fixme the following pathname should be an URL -->
<xsl:variable name="playersDataSource">http://www.fanfoot.com/test/players.xml</xsl:variable>
<!-- match everything not match elsewhere and do nothing with it! -->
<xsl:template match="*"/>
<!-- template rule matching source root element -->
<xsl:template match="/">
<scores>
<!-- 4 points for every goal scored. -->
<xsl:call-template name="goalScorers"/>
<!-- 2 points for every goal-assist -->
<xsl:call-template name="goalAssists"/>
<!-- 1 point for any player playing 45 minutes or more of a match (excludes injury time). -->
<xsl:call-template name="appearance"/>
<!-- 4 points for a Goalkeeper, Full Back or Centre Back who does not concede a goal whilst on the pitch, providing they play for 70 minutes or more. -->
<xsl:call-template name="cleanSheet"/>
<!-- Goalkeepers, Full Backs and Centre Backs will lose 1 point for every goal conceded whilst they are on the pitch. -->
<xsl:call-template name="goalsConceeded"/>
<!-- Any player receiving a Yellow Card will lose 1 point for each time they receive a card (i.e. first offence -1 pt., second offence -1 pt. (total -2 pts.)). -->
<xsl:call-template name="yellowCards"/>
<!-- Any player receiving a straight Red Card will lose 3 points. -->
<xsl:call-template name="sendingOffs"/>
</scores>
</xsl:template>
<!-- 4 points for every goal scored. -->
<xsl:template name="goalScorers">
<xsl:for-each select="//event[type='goal']">
<xsl:call-template name="getPointsNode">
<xsl:with-param name="playerName"><xsl:value-of select="./player"/></xsl:with-param>
<xsl:with-param name="points">4</xsl:with-param>
<xsl:with-param name="eventType">Goal</xsl:with-param>
</xsl:call-template>
</xsl:for-each>
</xsl:template>
<!-- 2 points for every goal-assist -->
<xsl:template name="goalAssists">
<xsl:for-each select="//event[type='assist']">
<xsl:call-template name="getPointsNode">
<xsl:with-param name="playerName"><xsl:value-of select="./player"/></xsl:with-param>
<xsl:with-param name="points">2</xsl:with-param>
<xsl:with-param name="eventType">Assist</xsl:with-param>
</xsl:call-template>
</xsl:for-each>
</xsl:template>
<!-- 1 point for any player playing 45 minutes or more of a match (excludes injury time). -->
<xsl:template name="appearance">
<xsl:for-each select="//event[type='teamStarter'] | //event[type='substituteStarter']">
<xsl:variable name="playerSurname"><xsl:value-of select="./player"/></xsl:variable>
<xsl:variable name="playerName">
<xsl:call-template name="getPlayerFullName">
<xsl:with-param name="playerSurname"><xsl:value-of select="$playerSurname"/></xsl:with-param>
</xsl:call-template>
</xsl:variable>
<xsl:choose>
<xsl:when test="starts-with($playerName, 'ERROR')">
<error>
<xsl:value-of select="concat('Unable to assign appearance points (', $playerName, ')')"/>
</error>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="timeOnPitch">
<xsl:call-template name="calculateTimeOnPitch">
<xsl:with-param name="playerFullName" select="$playerName"/>
<xsl:with-param name="playerSurname" select="$playerSurname"/>
</xsl:call-template>
</xsl:variable>
<xsl:if test="$timeOnPitch > 2699">
<xsl:call-template name="getPointsNode">
<xsl:with-param name="playerName"><xsl:value-of select="$playerName"/></xsl:with-param>
<xsl:with-param name="points">1</xsl:with-param>
<xsl:with-param name="eventType">Appearance</xsl:with-param>
</xsl:call-template>
</xsl:if>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:template>
<!-- 4 points for a Goalkeeper, Full Back or Centre Back who does not concede a goal whilst on the pitch, providing they play for 70 minutes or more. -->
<xsl:template name="cleanSheet">
<xsl:for-each select="//event[type='result']">
<xsl:variable name="homeTeam"><xsl:value-of select="homeTeam"/></xsl:variable>
<xsl:variable name="homeScore"><xsl:value-of select="homeScore"/></xsl:variable>
<xsl:variable name="awayTeam"><xsl:value-of select="awayTeam"/></xsl:variable>
<xsl:variable name="awayScore"><xsl:value-of select="awayScore"/></xsl:variable>
<xsl:for-each select="//event[type='teamStarter'] | //event[type='substituteStarter']">
<xsl:variable name="currentTeam"><xsl:value-of select="team"/></xsl:variable>
<xsl:variable name="playerFullName">
<xsl:call-template name="getPlayerFullName">
<xsl:with-param name="playerSurname"><xsl:value-of select="player"/></xsl:with-param>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="playerPosition">
<xsl:call-template name="getPlayerPosition">
<xsl:with-param name="playerSurname"><xsl:value-of select="player"/></xsl:with-param>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="timeOnPitch">
<xsl:call-template name="calculateTimeOnPitch">
<xsl:with-param name="playerFullName" select="$playerFullName"/>
<xsl:with-param name="playerSurname" select="player"/>
</xsl:call-template>
</xsl:variable>
<xsl:if test="$timeOnPitch > 4199">
<xsl:choose>
<xsl:when test="$currentTeam = $awayTeam">
<xsl:if test="$homeScore = 0">
<xsl:choose>
<xsl:when test="$playerPosition = 'Goalkeeper'">
<xsl:call-template name="getPointsNode">
<xsl:with-param name="playerName"><xsl:value-of select="$playerFullName"/></xsl:with-param>
<xsl:with-param name="playersTeam"><xsl:value-of select="$currentTeam"/></xsl:with-param>
<xsl:with-param name="points">4</xsl:with-param>
<xsl:with-param name="eventType">Goalkeeper Clean Sheet</xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:when test="$playerPosition = 'Full Back'">
<xsl:call-template name="getPointsNode">
<xsl:with-param name="playerName"><xsl:value-of select="$playerFullName"/></xsl:with-param>
<xsl:with-param name="playersTeam"><xsl:value-of select="$currentTeam"/></xsl:with-param>
<xsl:with-param name="points">4</xsl:with-param>
<xsl:with-param name="eventType">Full Back Clean Sheet</xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:when test="$playerPosition = 'Centre Back'">
<xsl:call-template name="getPointsNode">
<xsl:with-param name="playerName"><xsl:value-of select="$playerFullName"/></xsl:with-param>
<xsl:with-param name="playersTeam"><xsl:value-of select="$currentTeam"/></xsl:with-param>
<xsl:with-param name="points">4</xsl:with-param>
<xsl:with-param name="eventType">Centre Back Clean Sheet</xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:when test="$playerPosition = 'Midfield'">
</xsl:when>
<xsl:when test="$playerPosition = 'Forward'">
</xsl:when>
<xsl:otherwise>
<error>
<xsl:value-of select="concat('Unable to determine player position to award clean sheet bonus (', $playerFullName, ' of ', $currentTeam, ')')"/>
</error>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:when>
<xsl:when test="$currentTeam = $homeTeam">
<xsl:if test="$awayScore = 0">
<xsl:choose>
<xsl:when test="$playerPosition = 'Goalkeeper'">
<xsl:call-template name="getPointsNode">
<xsl:with-param name="playerName"><xsl:value-of select="$playerFullName"/></xsl:with-param>
<xsl:with-param name="playersTeam"><xsl:value-of select="$currentTeam"/></xsl:with-param>
<xsl:with-param name="points">4</xsl:with-param>
<xsl:with-param name="eventType">Goalkeeper Clean Sheet</xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:when test="$playerPosition = 'Full Back'">
<xsl:call-template name="getPointsNode">
<xsl:with-param name="playerName"><xsl:value-of select="$playerFullName"/></xsl:with-param>
<xsl:with-param name="playersTeam"><xsl:value-of select="$currentTeam"/></xsl:with-param>
<xsl:with-param name="points">4</xsl:with-param>
<xsl:with-param name="eventType">Full Back Clean Sheet</xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:when test="$playerPosition = 'Centre Back'">
<xsl:call-template name="getPointsNode">
<xsl:with-param name="playerName"><xsl:value-of select="$playerFullName"/></xsl:with-param>
<xsl:with-param name="playersTeam"><xsl:value-of select="$currentTeam"/></xsl:with-param>
<xsl:with-param name="points">4</xsl:with-param>
<xsl:with-param name="eventType">Centre Back Clean Sheet</xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:when test="$playerPosition = 'Midfield'">
</xsl:when>
<xsl:when test="$playerPosition = 'Forward'">
</xsl:when>
<xsl:otherwise>
<error>
<xsl:value-of select="concat('Unable to determine player position to award clean sheet bonus (', $playerFullName, ' of ', $currentTeam, ')')"/>
</error>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:when>
</xsl:choose>
</xsl:if>
</xsl:for-each>
</xsl:for-each>
</xsl:template>
<!-- Goalkeepers, Full Backs and Centre Backs will lose 1 point for every goal conceded whilst they are on the pitch. -->
<xsl:template name="goalsConceeded">
<xsl:for-each select="//event[type='goal']">
<xsl:variable name="goalMinutes"><xsl:value-of select="normalTimeMinutes"/></xsl:variable>
<xsl:variable name="scoringTeam">
<xsl:call-template name="getPlayerTeam">
<xsl:with-param name="playerFullName"><xsl:value-of select="player"/></xsl:with-param>
</xsl:call-template>
</xsl:variable>
<xsl:for-each select="//event[type='teamStarter'] | //event[type='substituteStarter']">
<xsl:variable name="playerFullName">
<xsl:call-template name="getPlayerFullName">
<xsl:with-param name="playerSurname"><xsl:value-of select="player"/></xsl:with-param>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="playerTeam">
<xsl:call-template name="getPlayerTeam">
<xsl:with-param name="playerSurname"><xsl:value-of select="player"/></xsl:with-param>
</xsl:call-template>
</xsl:variable>
<xsl:choose>
<xsl:when test="starts-with($scoringTeam, 'ERROR')">
<error>
<xsl:value-of select="concat('Unable to deduct conceeded goal points becuase cannot identify scoring team (', $scoringTeam, ')')"/>
</error>
</xsl:when>
<xsl:when test="starts-with($playerTeam, 'ERROR')">
<error>
<xsl:value-of select="concat('Unable to deduct conceeded goal points becuase cannot identify scoring team (', $playerTeam, ')')"/>
</error>
</xsl:when>
<xsl:when test="$playerTeam != $scoringTeam">
<!-- get player start time -->
<xsl:variable name="onMinutes">
<xsl:choose>
<!-- if the player was a teamStarter then start time is 00:00 -->
<xsl:when test="self::node()[type='teamStarter']">00</xsl:when>
<!-- if player was a teamSubstitute and they were subbed on then start time is xx:xx -->
<xsl:when test="//event[type='substitution' and playerOn=$playerFullName]"><xsl:value-of select="//event[type='substitution' and playerOn=$playerFullName]/normalTimeMinutes"/></xsl:when>
<!-- otherwise the player did not play at all -->
<xsl:otherwise>Did Not Play</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- get stop time -->
<xsl:variable name="offMinutes">
<xsl:choose>
<!-- if the player was subbed off then their stop time is xx:xx -->
<xsl:when test="//event[type='substitution' and playerOff=$playerFullName]"><xsl:value-of select="//event[type='substitution' and playerOff=$playerFullName]/normalTimeMinutes"/></xsl:when>
<!-- if the player was sent off then their stop time is xx:xx -->
<xsl:when test="//event[type='sendingOff' and player=$playerFullName]"><xsl:value-of select="//event[type='sendingOff' and player=$playerFullName]/normalTimeMinutes"/></xsl:when>
<!-- otherwise the stop time was 90:00 -->
<xsl:otherwise>90</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- test to see if the player was on the pitch when the goal was scored -->
<xsl:if test="$offMinutes != 'Did Not Play'">
<xsl:if test="$goalMinutes < $offMinutes and $goalMinutes > onMinutes">
<xsl:variable name="playerPosition">
<xsl:call-template name="getPlayerPosition">
<xsl:with-param name="playerSurname"><xsl:value-of select="player"/></xsl:with-param>
</xsl:call-template>
</xsl:variable>
<xsl:choose>
<xsl:when test="$playerPosition = 'Goalkeeper'">
<xsl:call-template name="getPointsNode">
<xsl:with-param name="playerName"><xsl:value-of select="$playerFullName"/></xsl:with-param>
<xsl:with-param name="playersTeam"><xsl:value-of select="$playerTeam"/></xsl:with-param>
<xsl:with-param name="points">-1</xsl:with-param>
<xsl:with-param name="eventType">Goalkeeper Conceeded Goal</xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:when test="$playerPosition = 'Full Back'">
<xsl:call-template name="getPointsNode">
<xsl:with-param name="playerName"><xsl:value-of select="$playerFullName"/></xsl:with-param>
<xsl:with-param name="playersTeam"><xsl:value-of select="$playerTeam"/></xsl:with-param>
<xsl:with-param name="points">-1</xsl:with-param>
<xsl:with-param name="eventType">Full Back Conceeded Goal</xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:when test="$playerPosition = 'Centre Back'">
<xsl:call-template name="getPointsNode">
<xsl:with-param name="playerName"><xsl:value-of select="$playerFullName"/></xsl:with-param>
<xsl:with-param name="playersTeam"><xsl:value-of select="$playerTeam"/></xsl:with-param>
<xsl:with-param name="points">-1</xsl:with-param>
<xsl:with-param name="eventType">Centre Back Conceeded Goal</xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:when test="$playerPosition = 'Midfield'">
</xsl:when>
<xsl:when test="$playerPosition = 'Forward'">
</xsl:when>
<xsl:otherwise>
<error>
<xsl:value-of select="concat('Unable to determine player position to deduct conceeded goal points (', $playerFullName, ' of ', $playerTeam, ')')"/>
</error>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:if>
</xsl:when>
</xsl:choose>
</xsl:for-each>
</xsl:for-each>
</xsl:template>
<!-- Any player receiving a Yellow Card will lose 1 point for each time they receive a card (i.e. first offence -1 pt., second offence -1 pt. (total -2 pts.)). -->
<xsl:template name="yellowCards">
<xsl:for-each select="//event[type='booking']">
<xsl:call-template name="getPointsNode">
<xsl:with-param name="playerName"><xsl:value-of select="player"/></xsl:with-param>
<xsl:with-param name="points">-1</xsl:with-param>
<xsl:with-param name="eventType">Yellow Card</xsl:with-param>
</xsl:call-template>
</xsl:for-each>
</xsl:template>
<!-- Any player receiving a straight Red Card will lose 3 points. -->
<!-- FIXME ensure a player sent off for two yellows does not get the -3 penalty, just the two -1's for the yellows -->
<!-- FIXME ensure a player recieveing 1 yellow and 1 red gets - 4 points (-1 + -3) -->
<xsl:template name="sendingOffs">
<xsl:for-each select="//event[type='sendingOff']">
<xsl:call-template name="getPointsNode">
<xsl:with-param name="playerName"><xsl:value-of select="player"/></xsl:with-param>
<xsl:with-param name="points">-3</xsl:with-param>
<xsl:with-param name="eventType">Sending Off</xsl:with-param>
</xsl:call-template>
</xsl:for-each>
</xsl:template>
<!-- Return the full player name -->
<xsl:template name="getPlayerFullName">
<xsl:param name="playerSurname"/>
<xsl:variable name="playerFirstName">
<xsl:value-of select="document($playersDataSource)/players/player[surname=$playerSurname]/firstName[@type='main']"/>
</xsl:variable>
<!-- Return the result -->
<xsl:choose>
<xsl:when test="string-length($playerFirstName) > 0"><xsl:value-of select="concat($playerFirstName, ' ', $playerSurname)"/></xsl:when>
<xsl:otherwise><xsl:value-of select="concat('ERROR: Unknown Player (', $playerSurname, ')')"/></xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- Return the player position -->
<xsl:template name="getPlayerPosition">
<xsl:param name="playerSurname"/>
<xsl:variable name="playerPosition">
<xsl:value-of select="document($playersDataSource)/players/player[surname=$playerSurname]/position"/>
</xsl:variable>
<!-- Return the result -->
<xsl:choose>
<xsl:when test="string-length($playerPosition) > 0"><xsl:value-of select="$playerPosition"/></xsl:when>
<xsl:otherwise><xsl:value-of select="concat('ERROR: Unknown Player Position (surname = ', $playerSurname, ')')"/></xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- Return the player team -->
<xsl:template name="getPlayerTeam">
<xsl:param name="playerFullName"/>
<xsl:param name="playerSurname"/>
<xsl:variable name="playerTeam">
<xsl:choose>
<xsl:when test="string-length($playerSurname) > 0">
<xsl:value-of select="document($playersDataSource)/players/player[surname=$playerSurname]/team"/>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="surname"><xsl:value-of select="substring-after($playerFullName, ' ')"/></xsl:variable>
<xsl:value-of select="document($playersDataSource)/players/player[surname=$surname]/team"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- Return the result -->
<xsl:choose>
<xsl:when test="string-length($playerTeam) > 0"><xsl:value-of select="$playerTeam"/></xsl:when>
<xsl:otherwise><xsl:value-of select="concat('ERROR: Unknown team for ', $playerFullName, $playerSurname, ')')"/></xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- Return the number of seconds a player was on the pitch -->
<xsl:template name="calculateTimeOnPitch">
<xsl:param name="playerFullName"/>
<xsl:param name="playerSurname"/>
<!-- get start time -->
<xsl:variable name="startMinutes">
<xsl:choose>
<!-- if the player started then their start time is 00:00 -->
<xsl:when test="//event[type='teamStarter' and player=$playerSurname]">0</xsl:when>
<!-- if the player was subbed on then their start time is xx:xx -->
<xsl:when test="//event[type='substitution' and playerOn=$playerFullName]"><xsl:value-of select="//event[type='substitution' and playerOn=$playerFullName]/normalTimeMinutes"/></xsl:when>
<!-- otherwise the player Did not play -->
<xsl:otherwise>Did not play</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="startSeconds">
<xsl:choose>
<!-- if the player started then their start time is 00:00 -->
<xsl:when test="//event[type='teamStarter' and player=$playerSurname]">0</xsl:when>
<!-- if the player was subbed on then their start time is xx:xx -->
<xsl:when test="//event[type='substitution' and playerOn=$playerFullName]"><xsl:value-of select="//event[type='substitution' and playerOn=$playerFullName]/normalTimeSeconds"/></xsl:when>
<!-- otherwise the player Did not play -->
<xsl:otherwise>Did not play</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- get stop time -->
<xsl:variable name="endMinutes">
<xsl:choose>
<!-- if the player was subbed off then their stop time is xx:xx -->
<xsl:when test="//event[type='substitution' and playerOff=$playerFullName]"><xsl:value-of select="//event[type='substitution' and playerOff=$playerFullName]/normalTimeMinutes"/></xsl:when>
<!-- if the player was sent off then their stop time is xx:xx -->
<xsl:when test="//event[type='sendingOff' and player=$playerFullName]"><xsl:value-of se...
[truncated message content] |