<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:dt="urn:schemas-microsoft-com:datatypes"
	xmlns:user="demon:xslt-function"
	xmlns:msxsl="urn:schemas-microsoft-com:xslt"
>
  <xsl:output method='xml' version='1.0' encoding='UTF-8' omit-xml-declaration="yes" indent="yes"/>
  <msxsl:script language="JScript" implements-prefix="user">
    <![CDATA[
       function truncate(str, len) {
      
        if ((str.length > len) && (len > 3))
          return str.substr(0, len - 3) + '...';
        else 
          return str.toString();

        }
    ]]>
  </msxsl:script>


  <xsl:template match="/">
    <xsl:apply-templates select="//players" />
  </xsl:template>

  <xsl:template match="players">

    <xsl:if test="count(player) = 0">
      <div class="noplayers">No players on server.</div>
    </xsl:if>

    <xsl:if test="count(player) != 0">
      <table id="tplayers" cellspacing="1">
        <xsl:attribute name="class"> 
        <xsl:if test="count(player)&gt;14">longlist</xsl:if>
        <xsl:if test="count(player)&lt;=14">shortlist</xsl:if>
          </xsl:attribute>
        <tr>
          <th>Name</th>
          <th>Score</th>
          <th>Time</th>
        </tr>


        <xsl:apply-templates select="player" >
          <xsl:sort select="@kills" data-type="number" order="descending"/>
        </xsl:apply-templates>

      </table>
    </xsl:if>
  </xsl:template>

  <xsl:template match="player">
    <tr>
      <td class="pname">
        <xsl:value-of select="text()"/>        
      </td>
      <td class="pkills">
        <xsl:value-of select="@kills"/>
      </td>
      <td class="pduration">
        <nobr><xsl:value-of select="@duration"/></nobr>
      </td>
    </tr>
  </xsl:template>
</xsl:stylesheet>