<?xml version="1.0" ?>
<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>


<xsl:output method="html" encoding="ISO-8859-1"
doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
doctype-system="DTD/xhtml1-strict.dtd"
indent="yes" /> 


<xsl:template match="/CHAMPIONNAT">
   <html xmlns="http://www.w3.org/1999/xhtml">
   <head>
   <title>Ligue <xsl:value-of select="@DIVISION"/>, saison <xsl:value-of select="@SAISON"/></title>
   <link rel="stylesheet" href="foot.css" />
   <meta name="robots" content="noindex" />
   </head>
   <body>
   <div class="pagelarge">
   <h1>
   Résultats de ligue <xsl:value-of select="@DIVISION"/>,
   saison <xsl:value-of select="@SAISON"/>
   </h1>

   <p>
     Cette page est produite dans le cadre d'exercices sur XSLT. Son contenu n'est peut-être pas pertinent.
   </p>
   <ul>
     <li>retour aux <a href="http://www.grappa.univ-lille3.fr/~torre/Enseignement/TPs/XML/Corrections/#xsltfoot">solutions des exercices XML</a></li>
     <li>retour aux <a href="http://www.grappa.univ-lille3.fr/~torre/Enseignement/TPs/XML/XSLT/">exercices XSLT</a></li>
     <li>retour à la page de <a href="http://www.grappa.univ-lille3.fr/~torre/">Fabien Torre</a></li>
   </ul>

   <h2>Statistiques sur les conclusions des rencontres</h2>

   <fieldset class="sommaire">
   <legend>Sommaire</legend>
   <ul>
   <xsl:apply-templates select="/CHAMPIONNAT/JOURNEE" mode="sommaire"/>
   </ul>
   </fieldset>




   <xsl:variable name="nb_matches" select="count(//RENCONTRE)" />

   <xsl:variable name="nb_victoires" select="count(//RENCONTRE[@SCORED &gt; @SCOREE])" />
   <xsl:variable name="pc_victoires" select="format-number(100.*$nb_victoires div $nb_matches,'##.##')" />

   <xsl:variable name="nb_defaites" select="count(//RENCONTRE[@SCORED &lt; @SCOREE])" />
   <xsl:variable name="pc_defaites" select="format-number(100.*$nb_defaites div $nb_matches,'##.##')" />

   <xsl:variable name="nb_nuls" select="count(//RENCONTRE[@SCORED = @SCOREE])" />
   <xsl:variable name="pc_nuls" select="format-number(100.*$nb_nuls div $nb_matches,'##.##')" />


   <table>
   <tr>
    <th>Victoires de l'équipe à domicile</th>
    <td align="right"><xsl:value-of select="$nb_victoires"/>/<xsl:value-of select="$nb_matches"/></td>
    <td align="right"><xsl:value-of select="$pc_victoires"/>%</td>
   </tr>

   <tr>
    <th>Victoires de l'équipe à l'extérieur</th>
    <td align="right"><xsl:value-of select="$nb_defaites"/>/<xsl:value-of select="$nb_matches"/></td>
    <td align="right"><xsl:value-of select="$pc_defaites"/>%</td>
   </tr>

   <tr>
    <th>Matches nul</th>
    <td align="right"><xsl:value-of select="$nb_nuls"/>/<xsl:value-of select="$nb_matches"/></td>
    <td align="right"><xsl:value-of select="$pc_nuls"/>%</td>
   </tr>
 
  </table>

  <br /><br />

  <embed src="stats.svg" width="400" height="400" type="image/svg+xml" />

  <hr />

  <xsl:apply-templates select="/CHAMPIONNAT/JOURNEE"/>

  </div>
  </body>
  </html>

</xsl:template>






<xsl:template match="/CHAMPIONNAT/JOURNEE" mode="sommaire">
   <li> <a href="#{@NUMERO}">journée <xsl:value-of select="@NUMERO"/></a></li>
</xsl:template>





<xsl:template match="/CHAMPIONNAT/JOURNEE">
<h2><a name="{@NUMERO}">Journée <xsl:value-of select="@NUMERO"/></a></h2>
<table width="40%">
   <xsl:apply-templates select="RENCONTRE"/>
</table>
</xsl:template>




<xsl:template match="RENCONTRE">
<tr>
<xsl:choose>
  <xsl:when test='@SCORED &gt; @SCOREE'>
    <th align="right"><xsl:value-of select="@DOMICILE"/></th>
    <th><xsl:value-of select="@SCORED"/></th>
    <td><xsl:value-of select="@SCOREE"/></td>
    <td align="left"><xsl:value-of select="@EXTERIEUR"/></td>
  </xsl:when>
  <xsl:when test='@SCORED &lt; @SCOREE'>
    <td align="right"><xsl:value-of select="@DOMICILE"/></td>
    <td><xsl:value-of select="@SCORED"/></td>
    <th><xsl:value-of select="@SCOREE"/></th>
    <th align="left"><xsl:value-of select="@EXTERIEUR"/></th>
  </xsl:when>
  <xsl:otherwise>
    <td align="right"><xsl:value-of select="@DOMICILE"/></td>
    <td><xsl:value-of select="@SCORED"/></td>
    <td><xsl:value-of select="@SCOREE"/></td>
    <td align="left"><xsl:value-of select="@EXTERIEUR"/></td>
  </xsl:otherwise>
</xsl:choose>
</tr>
</xsl:template>




</xsl:stylesheet>


