<?xml version="1.0" encoding="iso-8859-1"?>
<!-- 
lheo.xsl

Permet de générer du XHTML depuis du LHÉO/XML
Exemple de script XSLT...

$Id: lheo.xsl,v 1.4 2004/08/03 14:26:10 silber Exp $

Copyright 2003, 2004 DGEFP, Georges-Andre Silber.
-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
		xmlns="http://www.w3.org/1999/xhtml"
		xmlns:lheo="http://www.lheo.org/1.0"
		version="1.0">

  <xsl:output method="xml"
	      indent="yes"
	      encoding="iso-8859-1" />
  
  <xsl:param name="tables" select="'http://www.lheo.org/1.0/tables.xml'"/>
  <xsl:param name="urlstyle" select="'http://www.lheo.org/1.0/lheo.css'"/>

  <xsl:variable name="doctables" select="document($tables)"/>

  <xsl:template match="/">
    <html>
      <head>
	<title>Offres de formation</title>
	<style type="text/css" title="styleCourant">
	  <xsl:text>@import "</xsl:text>
	  <xsl:value-of select="$urlstyle"/>
	  <xsl:text>";</xsl:text>
	</style>
      </head>
      <body>
	<xsl:apply-templates select="//lheo:lheo"/>
      </body>
    </html>
  </xsl:template>

  <xsl:template match="lheo:lheo">
    <xsl:if test="count(lheo:offres/lheo:offre-formation) &gt; 1">
      <ul>
	<xsl:for-each select="lheo:offres/lheo:offre-formation">	   
	  <li>
	    <a href="#offre-{position()}">
	      <xsl:value-of select="lheo:action-formation/lheo:intitule-action"/>
	    </a>
	  </li>
	</xsl:for-each>
      </ul>
    </xsl:if>
    <xsl:apply-templates select="lheo:offres/lheo:offre-formation"/>
  </xsl:template>
  
  <xsl:template match="lheo:offre-formation">    
    <div class="offre">
      <a name="offre-{position()}"/>
      <h3 class="titreoffre">
	<xsl:value-of select="lheo:action-formation/lheo:intitule-action"/>
      </h3>
      <dl>
	<xsl:for-each select=".//node()[@atomique='2']">
	  <dt>
	    <b><xsl:value-of select="@libelle"/></b>
	  </dt>
	  <xsl:apply-templates mode="defaut"/>
	</xsl:for-each>
      </dl>
    </div>
  </xsl:template>

  <xsl:template match="node()[@atomique='1']" mode="defaut">
    <dd>
      <b><xsl:value-of select="@libelle"/></b>
      <p class="valeur">
	<xsl:apply-templates select="."/>
      </p>
    </dd>
  </xsl:template>


  <!--
    Coordonnees et adresses...
  -->
  <xsl:template match="lheo:coordonnees-organisme|lheo:contact-organisme|lheo:lieu-de-formation|lheo:contact-offre">
    <xsl:apply-templates select="*"/>
  </xsl:template>  
  <xsl:template match="lheo:coordonnees | lheo:coordonnees-libres">
    <xsl:apply-templates select="*"/>
  </xsl:template>
  <xsl:template match="lheo:lignesco|lheo:adresse|lheo:telfixe|lheo:fax|lheo:lignesad|lheo:web">
    <xsl:apply-templates select="*"/>
  </xsl:template>
  <xsl:template match="lheo:lignead|lheo:ligneco|lheo:ville">
    <xsl:value-of select="text()"/><br/>
  </xsl:template>
  <xsl:template match="lheo:courriel">
    <a href="mailto:{text()}">
      <xsl:value-of select="text()"/>
    </a>
    <br/>
  </xsl:template>
  <xsl:template match="lheo:urlweb">
    <a href="{text()}">
      <xsl:value-of select="text()"/>
    </a>
    <br/>
  </xsl:template>
  <xsl:template match="lheo:codepostal">
    <xsl:value-of select="text()"/><br/>
  </xsl:template>
  <xsl:template match="lheo:region">
    <xsl:text>Région: </xsl:text><xsl:value-of select="text()"/><br/>
  </xsl:template>
  <xsl:template match="lheo:code-INSEE-commune"/>
  <xsl:template match="lheo:telfixe/lheo:numtel">
    <xsl:text>Tél: </xsl:text><xsl:value-of select="text()"/><br/>
  </xsl:template>
  <xsl:template match="lheo:fax/lheo:numtel">
    <xsl:text>Fax: </xsl:text><xsl:value-of select="text()"/><br/>
  </xsl:template>
  <xsl:template match="lheo:portable/lheo:numtel">
    <xsl:text>Portable: </xsl:text><xsl:value-of select="text()"/><br/>
  </xsl:template>
  <xsl:template match="lheo:date">
    <xsl:value-of select="substring(.,1,2)"/>
    <xsl:text>/</xsl:text>
    <xsl:value-of select="substring(.,3,2)"/>
    <xsl:text>/</xsl:text>
    <xsl:value-of select="substring(.,5,4)"/>
  </xsl:template>

  <xsl:template match="node()[@table]">
    <xsl:variable name="cur" select="."/>
    <xsl:value-of select="$doctables/tables/table[@id=$cur/@table]/entree[cle=$cur/text()]/valeur[@xml:lang='fr']/text()"/>    
    <br/>
  </xsl:template>

  <xsl:template match="text()">
    <xsl:value-of select="."/>
  </xsl:template>

  <xsl:template match="lheo:rc">
    <br/>
  </xsl:template>

</xsl:stylesheet>
