<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="html" indent="yes" encoding="ISO-8859-1"/>
  <xsl:template match="/">
    <xsl:apply-templates select="statistics"/></xsl:template>
  <xsl:template match="statistics">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Untitled Document</title>
    <style type="text/css">
      .stats-title {
      background-color: #ddddff;
      border: 1px solid #cccccc;
      font-size: 150%;
      }
      .stats-subtitle {
      background-color: #ddddff;
      border: 1px solid #cccccc;
      font-size: 100%;
      }

      .stats-item {
      background-color: #eeeeff;
      border: 1px solid #cccccc;
      font-size: 100%;
      text-align: center;
      }

      .stats-item-col {
      background-color: #eeeeff;
      border: 1px solid #cccccc;
      font-size: 100%;
      text-align: center;
      width:200px;
      }

      .stats-table {
      background-color: #ffffdd;
      border: 1px dotted #cccccc;
      }

      .stats-pane {
      background-color: #ffffdd;
      border: 1px solid #cccccc;
      padding: 5px;
      text-align: left;
      }

      .stats-cell {
      background-color: #ffffdd;
      border: 1px solid #cccccc;
      padding: 5px;
      text-align: center;
      }
	  
      .stats-date {
      font-style:italic;
      font-size:70%;
      }
	  
      table {
      padding:0px;
      border:0px;
	  border-collapse:collapse;
      }
    </style>
    </head>
    <body>
    <table width="100%" cellspacing="20">
      <tr>
        <th width="100px" scope="col"><img src="../../statistics.jpg" width="64" height="64" /></th>
        <th width="100%" scope="col"><div class="stats-title">Statistiques <xsl:value-of select="@str-month"/>&#x00A0;<xsl:value-of select="@year"/></div></th>
      </tr>
    </table>
    <table width="400" style="text-align:left">
      <tr>
      <td class="stats-pane" scope="col">
        Total des précipitations : <xsl:value-of select="total-rainfall"/><br/>
        Nombre de jours pluvieux : <xsl:value-of select="nb-days-of-rainfall"/><br/>
		Nombre de jours de gel (&lt;0°C) : <xsl:value-of select="nb-days-of-freeze"/><br/>
		Nombre de jours de soleil (&gt;50%) : <xsl:value-of select="nb-days-of-sunshine"/><br/>
		<xsl:choose>
  <xsl:when test="floor(((nb-hours-of-sunshine)-floor(nb-hours-of-sunshine))*60) &lt; 10">
    Durée d'ensoleillement : <xsl:value-of select="floor(nb-hours-of-sunshine)"/>h0<xsl:value-of select="floor(((nb-hours-of-sunshine)-floor(nb-hours-of-sunshine))*60)"/><br/>
  </xsl:when>
  <xsl:when test="floor(((nb-hours-of-sunshine)-floor(nb-hours-of-sunshine))*60) &gt;= 10">
    Durée d'ensoleillement : <xsl:value-of select="floor(nb-hours-of-sunshine)"/>h<xsl:value-of select="floor(((nb-hours-of-sunshine)-floor(nb-hours-of-sunshine))*60)"/><br/>
	</xsl:when>
  </xsl:choose>
        Nombre de jours de forte chaleur (&gt;30°C) : <xsl:value-of select="nb-days-of-heat"/><br/>
		Nombre de nuits tropicales (&gt;20°C) : <xsl:value-of select="nb-tropical-nights"/>
      </td>
      </tr>
      
    </table>
    <br/>

      <table width="100%">
        <tr>
          <th scope="col" style="padding-right:10px;padding-left:10px;">
            <img src="../../temperature.jpg" width="32" height="32" />
          </th>
          <th width="100%" scope="col">
            <div class="stats-subtitle">
              Pression - Humidité - Température - UV
            </div>
          </th>
        </tr>
      </table>
      
      <table width="100%">
      <tr>
        <td></td>
        <td class="stats-item">Min</td>
        <td class="stats-item">Max</td>
        <td class="stats-item">Moyenne</td>
        <td class="stats-item">Taux max (/h)</td>
      </tr>
      <tr>
        <td class="stats-item-col">Température ext.</td>
        <td class="stats-cell"><xsl:value-of select="outdoor_temperature/min"/>
          <div class="stats-date"><xsl:value-of select="outdoor_temperature/min-date-text"/></div></td>
        <td class="stats-cell"><xsl:value-of select="outdoor_temperature/max"/>
          <div class="stats-date"><xsl:value-of select="outdoor_temperature/max-date-text"/></div></td>
        <td class="stats-cell"><xsl:value-of select="outdoor_temperature/mean"/></td>
        <td class="stats-cell">
          <table width="100%" span="2">
            <tr>
              <td style="text-align: center;"><xsl:value-of select="outdoor_temperature/max-pos-rate"/>
            <div class="stats-date"><xsl:value-of select="outdoor_temperature/max-pos-rate-date-text"/></div></td>
              <td style="text-align: center;"><xsl:value-of select="outdoor_temperature/max-neg-rate"/>
            <div class="stats-date">
              <xsl:value-of select="outdoor_temperature/max-neg-rate-date-text"/>
            </div>
            </td>
          </tr>
          </table>
        </td>
      </tr>
        <tr>
          <td class="stats-item-col">Tn/Tx</td>
          <td class="stats-cell">
            <xsl:value-of select="tn-min"/>
            <div class="stats-date">
              <xsl:value-of select="tn-min-date-text"/>
            </div>
          </td>
          <td class="stats-cell">
            <xsl:value-of select="tx-max"/>
            <div class="stats-date">
              <xsl:value-of select="tx-max-date-text"/>
            </div>
          </td>
          <td class="stats-cell">-</td>
          <td class="stats-cell">-</td>
        </tr>
      <tr>
	  <td class="stats-item-col">Température ext. sous abri</td>
        <td class="stats-cell"><xsl:value-of select="temperature_1/min"/>
          <div class="stats-date"><xsl:value-of select="temperature_1/min-date-text"/></div></td>
        <td class="stats-cell"><xsl:value-of select="temperature_1/max"/>
          <div class="stats-date"><xsl:value-of select="temperature_1/max-date-text"/></div></td>
        <td class="stats-cell"><xsl:value-of select="temperature_1/mean"/></td>
        <td class="stats-cell">
          <table width="100%" span="2">
            <tr>
              <td style="text-align: center;"><xsl:value-of select="temperature_1/max-pos-rate"/>
            <div class="stats-date"><xsl:value-of select="temperature_1/max-pos-rate-date-text"/></div></td>
              <td style="text-align: center;"><xsl:value-of select="temperature_1/max-neg-rate"/>
            <div class="stats-date">
              <xsl:value-of select="temperature_1/max-neg-rate-date-text"/>
            </div>
            </td>
          </tr>
          </table>
        </td>
      </tr>
        <tr>
		<td class="stats-item-col">Température int.</td>
        <td class="stats-cell"><xsl:value-of select="indoor_temperature/min"/>
          <div class="stats-date"><xsl:value-of select="indoor_temperature/min-date-text"/></div></td>
        <td class="stats-cell"><xsl:value-of select="indoor_temperature/max"/>
          <div class="stats-date"><xsl:value-of select="indoor_temperature/max-date-text"/></div></td>
        <td class="stats-cell"><xsl:value-of select="indoor_temperature/mean"/></td>
        <td class="stats-cell">
          <table width="100%" span="2">
            <tr>
              <td style="text-align: center;"><xsl:value-of select="indoor_temperature/max-pos-rate"/>
            <div class="stats-date"><xsl:value-of select="indoor_temperature/max-pos-rate-date-text"/></div></td>
              <td style="text-align: center;"><xsl:value-of select="indoor_temperature/max-neg-rate"/>
            <div class="stats-date">
              <xsl:value-of select="indoor_temperature/max-neg-rate-date-text"/>
            </div>
            </td>
          </tr>
          </table>
        </td>
      </tr>
        <tr>
        <td class="stats-item-col">Pression</td>
        <td class="stats-cell"><xsl:value-of select="relative_pressure/min"/>
          <div class="stats-date"><xsl:value-of select="relative_pressure/min-date-text"/></div></td>
        <td class="stats-cell"><xsl:value-of select="relative_pressure/max"/>
          <div class="stats-date"><xsl:value-of select="relative_pressure/max-date-text"/></div></td>
        <td class="stats-cell"><xsl:value-of select="relative_pressure/mean"/></td>
        <td class="stats-cell">
          <table width="100%" span="2">
            <tr>
              <td style="text-align: center;">
                <xsl:value-of select="relative_pressure/max-pos-rate"/>
                <div class="stats-date">
                  <xsl:value-of select="relative_pressure/max-pos-rate-date-text"/>
                </div>
              </td>
              <td style="text-align: center;">
                <xsl:value-of select="relative_pressure/max-neg-rate"/>
                <div class="stats-date">
                  <xsl:value-of select="relative_pressure/max-neg-rate-date-text"/>
                </div>
              </td>
            </tr>
          </table>
        </td>
      </tr>
      <tr>
	  <td class="stats-item-col">Indice UV</td>
        <td class="stats-cell"><xsl:value-of select="uv_index/min"/>
          <div class="stats-date"><xsl:value-of select="uv_index/min-date-text"/></div></td>
        <td class="stats-cell"><xsl:value-of select="uv_index/max"/>
          <div class="stats-date"><xsl:value-of select="uv_index/max-date-text"/></div></td>
		<td class="stats-cell"><xsl:value-of select="uv_index/mean"/></td>
       <td class="stats-cell">
          <table width="100%" span="2">
            <tr>
              <td style="text-align: center;">
                <xsl:value-of select="uv_index/max-pos-rate"/>
                <div class="stats-date">
                  <xsl:value-of select="uv_index/max-pos-rate-date-text"/>
                </div>
              </td>
              <td style="text-align: center;">
                <xsl:value-of select="uv_index/max-neg-rate"/>
                <div class="stats-date">
                  <xsl:value-of select="uv_index/max-neg-rate-date-text"/>
                </div>
              </td>
            </tr>
          </table>
        </td>
      </tr>
      <tr>
        <td class="stats-item-col">Humidité</td>
        <td class="stats-cell"><xsl:value-of select="outdoor_humidity/min"/></td>
        <td class="stats-cell"><xsl:value-of select="outdoor_humidity/max"/></td>
        <td class="stats-cell"><xsl:value-of select="outdoor_humidity/mean"/></td>
        <td class="stats-cell">
          <table width="100%" span="2">
            <tr>
              <td style="text-align: center;">
                <xsl:value-of select="outdoor_humidity/max-pos-rate"/>
                <div class="stats-date">
                  <xsl:value-of select="outdoor_humidity/max-pos-rate-date-text"/>
                </div>
              </td>
              <td style="text-align: center;">
                <xsl:value-of select="outdoor_humidity/max-neg-rate"/>
                <div class="stats-date">
                  <xsl:value-of select="outdoor_humidity/max-neg-rate-date-text"/>
                </div>
              </td>
            </tr>
          </table>
        </td>
      </tr>
      <tr>
        <td class="stats-item-col">Point de rosée</td>
        <td class="stats-cell"><xsl:value-of select="dew_point/min"/></td>
        <td class="stats-cell"><xsl:value-of select="dew_point/max"/></td>
        <td class="stats-cell"><xsl:value-of select="dew_point/mean"/></td>
        <td class="stats-cell">
          <table width="100%" span="2">
            <tr>
              <td style="text-align: center;">
                <xsl:value-of select="dew_point/max-pos-rate"/>
                <div class="stats-date">
                  <xsl:value-of select="dew_point/max-pos-rate-date-text"/>
                </div>
              </td>
              <td style="text-align: center;">
                <xsl:value-of select="dew_point/max-neg-rate"/>
                <div class="stats-date">
                  <xsl:value-of select="dew_point/max-neg-rate-date-text"/>
                </div>
              </td>
            </tr>
          </table>
        </td>
      </tr>
      <tr>
        <td class="stats-item-col">Facteur vent</td>
        <td class="stats-cell"><xsl:value-of select="wind_chill/min"/></td>
        <td class="stats-cell">-</td>
        <td class="stats-cell">-</td>
        <td class="stats-cell">-</td>
      </tr>
      <tr>
        <td class="stats-item-col">Humidex</td>
        <td class="stats-cell">-</td>
        <td class="stats-cell">
          <xsl:value-of select="heat_index/max"/>
        </td>
        <td class="stats-cell">-</td>
        <td class="stats-cell">-</td>
      </tr>
    </table>
      <br/>
        <img>
          <xsl:attribute name="src">
            ../<xsl:value-of select="@month"/>/graph-month-1.png
          </xsl:attribute>
        </img>
      <br/>
      <br/>
      <table width="100%">
        <tr>
          <th scope="col" style="padding-right:10px;padding-left:10px;">
            <img src="../../rainfall.jpg" width="32" height="32" />
          </th>
          <th width="100%" scope="col">
            <div class="stats-subtitle">
              Précipitations
            </div>
          </th>
        </tr>
      </table>

      <table width="100%">
        <tr>
          <td class="stats-item-col">Taux max</td>
          <td class="stats-cell">
            <xsl:value-of select="relative_rainfall/max-pos-rate"/>
            <div class="stats-date">
              <xsl:value-of select="relative_rainfall/max-pos-rate-date-text"/>
            </div>
          </td>
        </tr>
        <tr>
          <td class="stats-item-col">Précipitations max sur 1h</td>
          <td class="stats-cell">
            <xsl:value-of select="rainfall_1h/max"/>
            <div class="stats-date">
              <xsl:value-of select="rainfall_1h/max-date-text"/>
            </div>
          </td>
        </tr>
        <tr>
          <td class="stats-item-col">Précipitations max sur 24h</td>
          <td class="stats-cell">
            <xsl:value-of select="rainfall_24h/max"/>
            <div class="stats-date">
              <xsl:value-of select="rainfall_24h/max-date-text"/>
            </div>
          </td>
        </tr>
      </table>
      <br/>
      <img>
        <xsl:attribute name="src">
          ../<xsl:value-of select="@month"/>/graph-month-2.png
        </xsl:attribute>
      </img>
      <br/>
	  <br/>
	  <table width="100%">
        <tr>
          <th scope="col" style="padding-right:10px;padding-left:10px;">
            <img src="../../soleil.gif" width="40" height="40" />
          </th>
          <th width="100%" scope="col">
            <div class="stats-subtitle">
              Soleil
            </div>
          </th>
        </tr>
      </table>   
       <table width="100%">
        <tr>
          <td class="stats-item-col">Indice UV max</td>
          <td class="stats-cell">
            <xsl:value-of select="uv_index/max"/>
            <div class="stats-date">
              <xsl:value-of select="uv_index/max-date-text"/>
            </div>
          </td>
        </tr>
        <tr>
          <td class="stats-item-col">Quantité de soleil</td>
          <td class="stats-cell">
            <xsl:choose>
  <xsl:when test="floor(((nb-hours-of-sunshine)-floor(nb-hours-of-sunshine))*60) &lt; 10">
    <xsl:value-of select="floor(nb-hours-of-sunshine)"/>h0<xsl:value-of select="floor(((nb-hours-of-sunshine)-floor(nb-hours-of-sunshine))*60)"/><br/>
  </xsl:when>
  <xsl:when test="floor(((nb-hours-of-sunshine)-floor(nb-hours-of-sunshine))*60) &gt;= 10">
    <xsl:value-of select="floor(nb-hours-of-sunshine)"/>h<xsl:value-of select="floor(((nb-hours-of-sunshine)-floor(nb-hours-of-sunshine))*60)"/><br/>
	</xsl:when>
  </xsl:choose>
          </td>
        </tr>
        </table>  
      <br/>
	  <img>
        <xsl:attribute name="src">
          ../<xsl:value-of select="@month"/>/graph-month-4.png
        </xsl:attribute>
      </img>
      <br/>
	  <br/>
      <table width="100%" >
        <tr>
          <th scope="col" style="padding-right:10px;padding-left:10px;">
            <img src="../../wind.jpg" width="32" height="32" />
          </th>
          <th width="100%" scope="col">
            <div class="stats-subtitle">
              Vent
            </div>
          </th>
        </tr>
      </table>
      
    <table width="100%">
      <tr>
        <td></td>
        <td class="stats-item">Max</td>
        <td class="stats-item">Moyenne</td>
      </tr>
      <tr>
        <td class="stats-item-col">Vitesse</td>
        <td class="stats-cell"><xsl:value-of select="wind_speed/max"/>
          <div class="stats-date"><xsl:value-of select="wind_speed/max-date-text"/></div></td>
        <td class="stats-cell"><xsl:value-of select="wind_speed/mean"/></td>
      </tr>
      <tr>
        <td class="stats-item-col">Rafale</td>
          <td class="stats-cell"><xsl:value-of select="wind_gust/max"/>
          <div class="stats-date"><xsl:value-of select="wind_gust/max-date-text"/></div></td>
        <td class="stats-cell"><xsl:value-of select="wind_gust/mean"/></td>
      </tr>
      <tr>
        <td colspan="3" class="stats-cell" style="text-align:left;">Direction moyenne : <xsl:value-of select="wind_direction/mean"/>
        </td>
      </tr>
    </table>
      <br/>
      <img>
        <xsl:attribute name="src">
          ../<xsl:value-of select="@month"/>/graph-month-3.png
        </xsl:attribute>
      </img>
	  <br/>
    </body>
    </html>
  </xsl:template>
</xsl:stylesheet>
