Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?xml version = "1.0"?>
- <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
- <xsl:output
- method="html"
- encoding="windows-1251"
- doctype-public = "-//W3C//DTD HTML 4.0//EN"
- indent = "yes"
- />
- <xsl:strip-space elements="*"/>
- <xsl:template match="standings">
- <html>
- <head>
- <title>Standings</title>
- <link rel="stylesheet" href="../standings-wt.css" />
- </head>
- <body><table class="wrapper"><tr><td>
- <center>
- <xsl:apply-templates select="contest"/>
- </center>
- </td></tr></table></body>
- </html>
- </xsl:template>
- <xsl:template match="contest">
- <a name="{@name}">
- <h2>
- <xsl:value-of select="@name"/>
- </h2>
- </a>
- <p>
- <xsl:if test = "@time and @length">
- <xsl:call-template name="write-time">
- <xsl:with-param name="time" select="@time"/>
- </xsl:call-template>
- <xsl:text> of </xsl:text>
- <xsl:call-template name="write-time">
- <xsl:with-param name="time" select="@length"/>
- </xsl:call-template>
- <br/>
- </xsl:if>
- <xsl:if test = "@status">
- <xsl:text>status: </xsl:text>
- <xsl:value-of select="@status"/>
- <xsl:if test="@frozen='yes'">
- <xsl:text>, frozen</xsl:text>
- </xsl:if>
- </xsl:if>
- </p>
- <xsl:if test="count(session/problem/run)">
- <p>
- <xsl:text>runs: </xsl:text>
- <xsl:value-of select="count(session/problem/run)"/>
- <xsl:text>, accepted: </xsl:text>
- <xsl:value-of select="count(session/problem/run[@accepted = 'yes'])"/>
- <br/>
- <xsl:for-each select="session/problem/run[@accepted = 'yes']">
- <xsl:sort select="@time" data-type="number" order="descending"/>
- <xsl:if test="position() = 1">
- <xsl:text>last success: </xsl:text>
- <xsl:value-of select="../../@party"/>
- <xsl:text>, </xsl:text>
- <xsl:value-of select="../@alias"/>
- <xsl:text>, </xsl:text>
- <xsl:call-template name="write-time">
- <xsl:with-param name="time" select="@time"/>
- </xsl:call-template>
- </xsl:if>
- </xsl:for-each>
- <br/>
- </p>
- </xsl:if>
- <xsl:variable name="challenge-problems" select="challenge/problem"/>
- <table border="0" cellspacing="0" cellpadding="1">
- <tr bgcolor="#ffffff">
- <th class="party">
- <xsl:text>Team</xsl:text>
- </th>
- <xsl:for-each select="$challenge-problems">
- <th class="problem">
- <xsl:value-of select="@alias"/>
- </th>
- </xsl:for-each>
- <th class="solved">
- <xsl:text>=</xsl:text>
- </th>
- <th class="penalty">
- <xsl:text>Time</xsl:text>
- </th>
- <th class="rank">
- <xsl:text>Rank</xsl:text>
- </th>
- </tr>
- <tr height="3">
- <td colspan="{4 + count($challenge-problems)}">
- <hr size="1" color="#000000"/>
- </td>
- </tr>
- <xsl:for-each select="session">
- <xsl:sort select="@solved" data-type="number" order="descending"/>
- <xsl:sort select="@penalty" data-type="number" order="ascending"/>
- <xsl:variable name="session-problems" select="problem"/>
- <xsl:variable name="cursolved" select="@solved"/>
- <xsl:variable name="unique">
- <xsl:choose>
- <xsl:when test="count(following-sibling::session[@solved = $cursolved]) = 0">1</xsl:when>
- <xsl:otherwise>0</xsl:otherwise>
- </xsl:choose>
- </xsl:variable>
- <xsl:variable name="solved" select="count(following-sibling::session[not(following-sibling::session/@solved = @solved)])+$unique"/>
- <tr>
- <xsl:choose>
- <xsl:when test="($solved mod 2 = 1) and (position() mod 2 = 0)">
- <xsl:attribute name = "bgcolor">#f8f8f8</xsl:attribute>
- </xsl:when>
- <xsl:when test="($solved mod 2 = 1) and (position() mod 2 = 1)">
- <xsl:attribute name = "bgcolor">#ffffff</xsl:attribute>
- </xsl:when>
- <xsl:when test="($solved mod 2 = 0) and (position() mod 2 = 1)">
- <xsl:attribute name = "bgcolor">#d0f0ff</xsl:attribute>
- </xsl:when>
- <xsl:when test="($solved mod 2 = 0) and (position() mod 2 = 0)">
- <xsl:attribute name = "bgcolor">#c8e8f8</xsl:attribute>
- </xsl:when>
- </xsl:choose>
- <td class="party">
- <xsl:value-of select="@party"/>
- </td>
- <xsl:for-each select="$challenge-problems">
- <td>
- <xsl:apply-templates select="$session-problems[@alias = current()/@alias]"/>
- </td>
- </xsl:for-each>
- <td>
- <xsl:number value="@solved"/>
- </td>
- <td class="penalty">
- <xsl:number value="@penalty" format="1" />
- </td>
- <td class="rank">
- <xsl:variable name="solved" select="@solved"/>
- <xsl:variable name="penalty" select="@penalty"/>
- <xsl:number value="position()-count(preceding::session[@solved=$solved and @penalty=$penalty])"/>
- </td>
- </tr>
- </xsl:for-each>
- <tr height="3">
- <td colspan="{4 + count($challenge-problems)}">
- <hr size="1" color="#000000"/>
- </td>
- </tr>
- <tr>
- <td>Total runs</td>
- <xsl:for-each select="$challenge-problems">
- <td>
- <xsl:value-of select="count(//problem[@alias = current()/@alias]/run)"/>
- </td>
- </xsl:for-each>
- </tr>
- <tr>
- <td>Accepted</td>
- <xsl:for-each select="$challenge-problems">
- <td>
- <xsl:value-of select="count(//problem[@alias = current()/@alias]/run[@accepted = 'yes'])"/>
- </td>
- </xsl:for-each>
- </tr>
- <tr>
- <td>Rejected</td>
- <xsl:for-each select="$challenge-problems">
- <td>
- <xsl:value-of select="count(//problem[@alias = current()/@alias]/run[@accepted != 'yes'])"/>
- </td>
- </xsl:for-each>
- </tr>
- </table>
- </xsl:template>
- <xsl:template match="problem">
- <xsl:if test="@attempts = 0">.</xsl:if>
- <xsl:if test="@attempts != 0">
- <xsl:choose>
- <xsl:when test="@accepted = 0">
- <b>-<xsl:number value="@attempts"/></b>
- </xsl:when>
- <xsl:otherwise>
- <i>
- <xsl:if test="@attempts = 1">+</xsl:if>
- <xsl:if test="@attempts != 1">+<xsl:number value="@attempts - 1"/></xsl:if>
- <br/>
- <s>
- <xsl:call-template name="write-short-time">
- <xsl:with-param name="time" select="@time"/>
- </xsl:call-template>
- </s>
- </i>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:if>
- </xsl:template>
- <!--
- <xsl:template name="write-time">
- <xsl:param name="time"/>
- <xsl:number value="floor($time div 3600000)" format="0"/>
- <xsl:text>:</xsl:text>
- <xsl:number value="floor($time div 60000) mod 60" format="00"/>
- <xsl:text>:</xsl:text>
- <xsl:number value="floor($time div 1000) mod 60" format="00"/>
- </xsl:template>
- <xsl:template name="write-short-time">
- <xsl:param name="time"/>
- <xsl:number value="floor($time div 60000)" format="0"/>
- <xsl:text>:</xsl:text>
- <xsl:number value="floor($time div 1000) mod 60" format="00"/>
- </xsl:template>
- -->
- <xsl:template name="write-time">
- <xsl:param name="time"/>
- <xsl:number value="floor($time div 3600000)" format="0"/>
- <xsl:text>:</xsl:text>
- <xsl:number value="floor(floor($time div 60000) mod 60 div 10)" /><xsl:number value="floor($time div 60000) mod 60 mod 10" />
- <xsl:text>:</xsl:text>
- <xsl:number value="floor(floor($time div 1000) mod 60 div 10)" /><xsl:number value="floor($time div 1000) mod 60 mod 10" />
- </xsl:template>
- <xsl:template name="write-short-time">
- <xsl:param name="time"/>
- <xsl:number value="floor($time div 60000)" format="0"/>
- <xsl:text>:</xsl:text>
- <xsl:number value="floor(floor($time div 1000) mod 60 div 10)" /><xsl:number value="floor($time div 1000) mod 60 mod 10" />
- </xsl:template>
- </xsl:stylesheet>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement