﻿<?xml version="1.0"?>
<!--                                   -->
<!-- Last update: 23 February 2012     -->
<!-- Copyright (c) 2009-2011 O. Narat. -->
<!-- All rights reserved.              -->
<!--                                   -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:template match="/">
    <xsl:variable name="n_philosophers" select="count(philosophers/philosopher)"/>
    <xsl:variable name="width_col_1" select="80"/>
    <xsl:variable name="width_col_2" select="160"/>
    <xsl:variable name="width_col_3" select="80"/>
    <xsl:variable name="width_col_4" select="320"/>
    <html>
      <head>
        <title>Philosophes (<xsl:value-of select="$n_philosophers"/>)</title>
        <link rel="stylesheet" type="text/css" href="../../../style/style.css"/>
      </head>
      <body>
        <p align="center" style="text-align:center;">
          <h1 align="center" style="text-align:center;">Philosophes</h1>
          <table border="1" align="center" style="text-align:center;">
            <tr align="center" style="font: normal bold 10.0pt verdana, sans-serif;text-align:center;">
              <th>
                <xsl:attribute name="width"><xsl:value-of select="$width_col_1"/></xsl:attribute>
                #
              </th>
              <th>
                <xsl:attribute name="width"><xsl:value-of select="$width_col_2"/></xsl:attribute>
                Philosophe <br/>(<xsl:value-of select="$n_philosophers"/> philosophes)
              </th>
              <th>
                <xsl:attribute name="width"><xsl:value-of select="$width_col_3"/></xsl:attribute>
                Pays
              </th>
              <th>
                <xsl:attribute name="width"><xsl:value-of select="$width_col_4"/></xsl:attribute>
                Images / citations
              </th>
            </tr>
            <xsl:for-each select="philosophers/philosopher">
              <tr align="left" style="font: normal normal 10.0pt verdana, sans-serif;text-align:left;">
                <!--   -->
                <!-- # -->
                <!--   -->
                <td>
                  <xsl:attribute name="width"><xsl:value-of select="$width_col_1"/></xsl:attribute>
                  <p>
                    # <xsl:value-of select="format-number(position(), '00')"/> / <xsl:value-of select="last()"/>
                  </p>
                </td>
                <!--             -->
                <!-- Philosopher -->
                <!--             -->
                <td align="center" style="font: normal normal 10.0pt verdana, sans-serif;text-align:center;">
                  <xsl:attribute name="width"><xsl:value-of select="$width_col_2"/></xsl:attribute>
                  <p>
                    <img>
                      <xsl:attribute name="width">80</xsl:attribute>
                      <xsl:attribute name="height">80</xsl:attribute>
                      <xsl:attribute name="src">../<xsl:value-of select="name"/>.gif</xsl:attribute>
                      <xsl:attribute name="alt"><xsl:value-of select="fullName"/></xsl:attribute>
                      <xsl:attribute name="title"><xsl:value-of select="fullName"/></xsl:attribute>
                    </img>
                    <br/>
                    <xsl:value-of select="fullName"/>
                  </p>
                </td>
                <!--         -->
                <!-- Country -->
                <!--         -->
                <td align="center" style="font: normal normal 10.0pt verdana, sans-serif;text-align:center;">
                  <xsl:attribute name="width"><xsl:value-of select="$width_col_3"/></xsl:attribute>
                  <p>
                    <img>
                      <xsl:attribute name="src">../../flags/<xsl:value-of select="country"/>.gif</xsl:attribute>
                      <xsl:attribute name="alt"><xsl:value-of select="country"/></xsl:attribute>
                      <xsl:attribute name="title"><xsl:value-of select="country"/></xsl:attribute>
                    </img>
                  </p>
                </td>
                <!--                 -->
                <!-- Images / quotes -->
                <!--                 -->
                <td>
                  <xsl:attribute name="width"><xsl:value-of select="$width_col_4"/></xsl:attribute>
                  <xsl:variable name="name" select="name"/>
                  <xsl:variable name="philosopher" select="document(concat($name, '.xml'))/philosopher"/>
                  <xsl:variable name="n_img" select="count($philosopher/img)"/>
                  <xsl:if test="$n_img > 0">
                    <a>
                      <xsl:attribute name="href">../<xsl:value-of select="$philosopher/img[1]/src"/></xsl:attribute>
                      <img>
                        <xsl:attribute name="width">160</xsl:attribute>
                        <xsl:attribute name="height">160</xsl:attribute>
                        <xsl:attribute name="src">../<xsl:value-of select="$philosopher/img[1]/src"/></xsl:attribute>
                        <xsl:attribute name="alt">
                          <xsl:choose>
                            <xsl:when test="not($philosopher/img[1]/caption[@language='fr'])">
                              <xsl:value-of select="$philosopher/img[1]/caption"/>
                            </xsl:when>
                            <xsl:otherwise>
                              <xsl:value-of select="$philosopher/img[1]/caption[@language='fr']"/>
                            </xsl:otherwise>
                          </xsl:choose>
						</xsl:attribute>
                        <xsl:attribute name="title">
                          <xsl:choose>
                            <xsl:when test="not($philosopher/img[1]/caption[@language='fr'])">
                              <xsl:value-of select="$philosopher/img[1]/caption"/>
                            </xsl:when>
                            <xsl:otherwise>
                              <xsl:value-of select="$philosopher/img[1]/caption[@language='fr']"/>
                            </xsl:otherwise>
                          </xsl:choose>
						</xsl:attribute>
                      </img>
                    </a>
                  </xsl:if>
                  <xsl:if test="$n_img > 1">
                    <a>
                      <xsl:attribute name="href">../<xsl:value-of select="$philosopher/img[2]/src"/></xsl:attribute>
                      <img>
                        <xsl:attribute name="width">160</xsl:attribute>
                        <xsl:attribute name="height">160</xsl:attribute>
                        <xsl:attribute name="src">../<xsl:value-of select="$philosopher/img[2]/src"/></xsl:attribute>
                        <xsl:attribute name="alt">
                          <xsl:choose>
                            <xsl:when test="not($philosopher/img[2]/caption[@language='fr'])">
                              <xsl:value-of select="$philosopher/img[2]/caption"/>
                            </xsl:when>
                            <xsl:otherwise>
                              <xsl:value-of select="$philosopher/img[2]/caption[@language='fr']"/>
                            </xsl:otherwise>
                          </xsl:choose>
						</xsl:attribute>
                        <xsl:attribute name="title">
                          <xsl:choose>
                            <xsl:when test="not($philosopher/img[2]/caption[@language='fr'])">
                              <xsl:value-of select="$philosopher/img[2]/caption"/>
                            </xsl:when>
                            <xsl:otherwise>
                              <xsl:value-of select="$philosopher/img[2]/caption[@language='fr']"/>
                            </xsl:otherwise>
                          </xsl:choose>
						</xsl:attribute>
                      </img>
                    </a>
                  </xsl:if>
                  <br/>
                  <br/>
                  <xsl:if test="$n_img > 2">
                    <a>
                      <xsl:attribute name="href"><xsl:value-of select="concat($name, '.xml')"/></xsl:attribute>
                      Autres images (<xsl:value-of select="$n_img"/>)...
                    </a>
                    <br/>
                    <br/>
                  </xsl:if>
                  <xsl:variable name="src_quotes" select="document(concat($name, '.xml'))/philosopher/src_quotes[@language='fr']"/>
                  <xsl:variable name="n_quotes" select="count(document($src_quotes)/quotes/quote)"/>
                  <xsl:if test="$n_quotes > 0">
                    <xsl:value-of select="document($src_quotes)/quotes/quote[1]"/>
                    <br/>
                    <br/>
                  </xsl:if>
                  <xsl:if test="$n_quotes > 1">
                    <a>
                      <xsl:attribute name="href"><xsl:value-of select="$src_quotes"/></xsl:attribute>
                      Autres citations (<xsl:value-of select="$n_quotes"/>)...
                    </a>
                    <br/>
                    <br/>
                  </xsl:if>
                </td>
              </tr>
            </xsl:for-each>
          </table>
        </p>
      </body>
    </html>
  </xsl:template>
</xsl:stylesheet>

