<?xml version="1.0" encoding="ISO-8859-15" ?>

<xsl:stylesheet
  version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns="http://www.w3.org/TR/xhtml1/strict"
>

<xsl:output method="html" />

<xsl:template match="/">
<html>
  <xsl:apply-templates select="//project" mode="head" />
<body>
  <xsl:apply-templates select="//project" mode="body" />
  <xsl:apply-templates select="//object" />
  <hr size="1" />
  <address><xsl:text>Généré avec $Id: test.xsl,v 1.4 2002/08/04 15:33:27 chips Exp $</xsl:text></address>
</body>
</html>
</xsl:template>

<xsl:template match="project" mode="head">
  <head>
    <title><xsl:text>Projet «&#160;</xsl:text><xsl:value-of select="info/@project"/><xsl:text>&#160;»</xsl:text></title>
    <meta name="DESCRIPTION"><xsl:attribute name="value"><xsl:value-of select="info/@description"/></xsl:attribute></meta>
    <meta name="AUTHOR"><xsl:attribute name="value"><xsl:value-of select="info/@author"/></xsl:attribute></meta>
    <meta name="VERSION"><xsl:attribute name="value"><xsl:value-of select="info/rcs/@header"/></xsl:attribute></meta>
  </head>
</xsl:template>

<xsl:template match="project" mode="body">
  <h1><xsl:text>Projet «&#160;</xsl:text><xsl:value-of select="info/@project"/><xsl:text>&#160;»</xsl:text><hr size="1" /></h1>
  <ul>
    <li><xsl:text>Description : </xsl:text><xsl:value-of select="info/@description"/></li>
    <li><xsl:text>Auteur(s) : </xsl:text><xsl:value-of select="info/@author"/></li>
    <li><xsl:text>RCS : </xsl:text><tt><xsl:value-of select="info/rcs/@header"/></tt></li>
  </ul>
  <h2><xsl:text>Base de données «&#160;</xsl:text><tt><xsl:value-of select="@name"/></tt><xsl:text>&#160;»</xsl:text><hr size="1" /></h2>
  <h3><xsl:text>Description</xsl:text></h3>
  <blockquote>
    <p><xsl:value-of select="doc"/></p>
  </blockquote>
  <h3><xsl:text>Objets</xsl:text></h3>
  <blockquote><dl>
    <xsl:for-each select="object">
      <dt><xsl:number value="position()" format="1. "/><a><xsl:attribute name="href">#<xsl:value-of select="@name"/></xsl:attribute><tt><xsl:value-of select="@name"/></tt></a></dt>
	<dd><xsl:for-each select="attribute">
	  <tt><xsl:value-of select="@name"/></tt>
	  <xsl:if test="not(position()=last())"><xsl:text>, </xsl:text></xsl:if>
	</xsl:for-each></dd>
    </xsl:for-each>
  </dl></blockquote>
</xsl:template>

<xsl:template match="object">
  <h2><xsl:number value="position()" format="1. "/><a><xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute></a><xsl:text>Objet «&#160;</xsl:text><tt><xsl:value-of select="@name"/></tt><xsl:text>&#160;»</xsl:text><hr size="1" /></h2>
  <h3>Description</h3>
  <blockquote>
    <p><xsl:value-of select="doc"/></p>
  </blockquote>
  <h3>Attributs</h3>
  <blockquote>
  <table border="1" cellspacing="0" cellpadding="2" width="100%">
    <tr>
      <th>Nom</th>
      <th>Type</th>
<!--
      <th>Inc. Auto.</th>
      <th>Clé primaire</th>
-->
      <th>Description</th>
    </tr>
  <xsl:for-each select="attribute">
    <tr>
      <xsl:choose>
        <xsl:when test="@card &gt; 0">
          <xsl:choose>
	    <xsl:when test="@primarykey = 'true'">
      <td width="20%" align="left"><tt><b><a><xsl:attribute name="href">#<xsl:value-of select="@type"/></xsl:attribute><xsl:value-of select="@name"/>(<xsl:value-of select="@cardinalite"/>)</a></b></tt></td>
            </xsl:when>
	    <xsl:otherwise>
      <td width="20%" align="left"><tt><a><xsl:attribute name="href">#<xsl:value-of select="@type"/></xsl:attribute><xsl:value-of select="@name"/>(<xsl:value-of select="@cardinalite"/>)</a></tt></td>
	    </xsl:otherwise>
          </xsl:choose>
        </xsl:when>
        <xsl:otherwise>
	  <xsl:choose>
	    <xsl:when test="@primarykey = 'true'">
		<td align="left"><tt><b><xsl:value-of select="@name"/></b></tt></td>
            </xsl:when>
	    <xsl:otherwise>
		<td width="20%" align="left"><tt><xsl:value-of select="@name"/></tt></td>
	    </xsl:otherwise>
          </xsl:choose>
        </xsl:otherwise>
      </xsl:choose>
      <xsl:choose>
        <xsl:when test="@length &gt; 0">
      <td width="20%" align="center"><xsl:value-of select="@type"/>(<xsl:value-of select="@length"/>)</td>
        </xsl:when>
        <xsl:otherwise>
      <td width="20%" align="center"><xsl:value-of select="@type"/></td>
        </xsl:otherwise>
      </xsl:choose>
<!--
      <td width="10%" align="center"><xsl:call-template name="printBoolean"><xsl:with-param name="value"><xsl:value-of select="@autoinc"   /></xsl:with-param></xsl:call-template></td>
      <td width="10%" align="center"><xsl:call-template name="printBoolean"><xsl:with-param name="value"><xsl:value-of select="@primarykey"/></xsl:with-param></xsl:call-template></td>
-->
      <td width="40%" align="left"  ><xsl:call-template name="printString" ><xsl:with-param name="value"><xsl:value-of select="doc"        /></xsl:with-param></xsl:call-template>&#160;</td>
    </tr>
  </xsl:for-each>
  </table>
  </blockquote>
  <h3>Index</h3>
  <blockquote>
    <p>à compléter.</p>
  </blockquote>
  <h3>Références</h3>
  <blockquote>
    <p>à compléter.</p>
  </blockquote>
</xsl:template>

<!-- afficher une chaîne de caractères -->
<xsl:template name="printString">
  <xsl:param name="value"></xsl:param>
  <xsl:choose>
    <xsl:when test="string($value)=''">
      <xsl:text>&#160;</xsl:text>
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="$value"/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

<!-- afficher un booléen -->
<xsl:template name="printBoolean">
  <xsl:param name="value"></xsl:param>
  <xsl:value-of select="$value"/>
  <xsl:choose>
    <xsl:when test="$value">
      <xsl:text>Oui</xsl:text>
    </xsl:when>
    <xsl:when test="string($value)=''">
      <xsl:text>Non</xsl:text>
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="$value"/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

</xsl:stylesheet>

