<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

<!-- Header labels -->
<xsl:variable name="HeaderFilename">Filename</xsl:variable>
<xsl:variable name="HeaderCompressedSize">Compressed size</xsl:variable>
<xsl:variable name="HeaderUncompressedSize">Uncompressed size</xsl:variable>
<xsl:variable name="HeaderCRC32">CRC32</xsl:variable>

<!-- Show/Hide settings. Set to 1 to show and 0 to hide -->
<xsl:variable name="ShowCRC32">1</xsl:variable>

<!-- Use this to enable downloading of files from the archive -->
<xsl:variable name="EnableDownload">1</xsl:variable>
<xsl:variable name="CBZIPPath">http://www.mysite.com/cgi-bin/CBZIP.exe</xsl:variable>

<!-- This is the stripe color -->
<xsl:variable name="StripeColor">CED0FE</xsl:variable>
<!--xsl:variable name="StripeColor">E0EDFF</xsl:variable-->


<xsl:template match="/">
    <table style="width: 95%; font-family: verdana; font-size: 10px; border: 0px; background-color: #FFFFFF;" align="center">
      <tr>
        <th style="border-bottom: 1px solid #000000;"><xsl:value-of select="$HeaderFilename" /></th>
        <th style="border-bottom: 1px solid #000000; width: 135px;"><xsl:value-of select="$HeaderCompressedSize" /></th>
        <th style="border-bottom: 1px solid #000000; width: 135px;"><xsl:value-of select="$HeaderUncompressedSize" /></th>
        <xsl:if test="$ShowCRC32 = 1">
          <th style="border-bottom: 1px solid #000000; width: 135px;"><xsl:value-of select="$HeaderCRC32" /></th>
        </xsl:if>
      </tr>
      <xsl:for-each select="root/zipinfo/files/file">
      <xsl:sort select="filename" order="ascending" />
      <tr>
        <xsl:if test="(position() mod 2) = 1">
          <xsl:attribute name="style">
            background: #<xsl:value-of select="$StripeColor" />;
          </xsl:attribute>
        </xsl:if>
        <td>
          <xsl:choose>
            <xsl:when test="$EnableDownload = 1">
              <a title="Get file">
                <xsl:attribute name="href">
                  <xsl:value-of select="$CBZIPPath" />/getfile?filename=<xsl:value-of select="/root/zipinfo/filename" />&amp;target=<xsl:value-of select="filename" />
                </xsl:attribute>
                <xsl:value-of select="filename" />
              </a>
            </xsl:when>
            <xsl:otherwise>
              <xsl:value-of select="filename" />
            </xsl:otherwise>
          </xsl:choose>
        </td>
        <!-- Choose statement to remove the word "bytes" from compressed folders -->
        <xsl:choose>
          <xsl:when test='string-length(compsize)=0'>
            <td align="right"></td>
            <td align="right"></td>
          </xsl:when>
          <xsl:otherwise>
            <td align="right"><xsl:value-of select="compsize" /> bytes</td>
            <td align="right"><xsl:value-of select="uncompsize" /> bytes</td>
          </xsl:otherwise>
        </xsl:choose>
        <xsl:if test="$ShowCRC32 = 1">
          <td align="right"><xsl:value-of select="crc32" /></td>
        </xsl:if>
      </tr>
      </xsl:for-each>
      <tr>
        <td colspan="4" align="right"><b>Generator:</b>&#160;<a href="http://www.crazybeavers.se/" title="Visit CrazyBeaver Software!"><xsl:value-of select="root/dllinfo/name" /></a> - <b>Version:</b>&#160;<xsl:value-of select="root/dllinfo/version" /></td>
      </tr>
    </table>
</xsl:template>
</xsl:stylesheet>