<?xml version="1.0" encoding="UTF-8"?>
<!--
This file is part of IREL, "Instruments de Recherche En Ligne",
<http://www.archivesnationales.culture.gouv.fr/caom/fr/index_irel.html>.
Copyright © 2008, 2009 : ANOM, PASS-TECH

Archives nationales d’outre-mer (ANOM, France)
29, chemin du moulin Detesta
13090 Aix-en-Provence
<http://www.archivesnationales.culture.gouv.fr/caom/fr/>
anom.aix@culture.gouv.fr

PASS-TECH
26, rue Louis Braille
F-75012 Paris
<http://pass-tech.fr/>
contact@pass-tech.fr

IREL is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

IREL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with IREL application; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

$Date: 2008-09-06 17:25:29 +0200 (sam., 06 sept. 2008) $:
$Author: frederic $:
$Rev: 350 $:
-->
<!--
Quelques outils utiles pour la transformation dans le navigateur.
Feuille à importer
 -->
<xsl:transform version="1.1"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns="http://www.w3.org/1999/xhtml"
>
  <!-- XSLT à inclure (pas importer) pour le XML traité -->
  <xsl:include href="eac2html.xsl"/>
  <xsl:output indent="no" method="xml" encoding="UTF-8" cdata-section-elements="cdata"/>
  <!-- récupérer le dossier de l'XSLT, par le chemin d'appel dans le document XML -->
	<xsl:param name="base">
	</xsl:param>
	<!-- calcul du chemin relatif du fichier css -->
	<xsl:param name="css">
		<xsl:call-template name="getBase"/>
		<xsl:text>eac.css</xsl:text>
	</xsl:param>

	<!-- modèle racine -->
	<xsl:template match="/">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
      <head>
        <title>
          <!-- à fixer par l'importeur -->
          <xsl:value-of select="$title"/>
        </title>
        <meta http-equiv="Content-type" content="text/html; charset=UTF-8"/>
        <xsl:call-template name="css"/>
      </head>
      <body>
        <div id="container">
          <xsl:apply-templates/>
        </div>
      </body>
    </html>
	</xsl:template>



  <!-- pour obtenir un chemin relatif à l'XSLT appliquée -->
	<xsl:template name="getBase">
		<xsl:param name="path" select="/processing-instruction('xml-stylesheet')"/>
		<xsl:choose>
			<xsl:when test="contains($path, 'href=&quot;')">
				<xsl:call-template name="getBase">
					<xsl:with-param name="path" select="substring-after($path, 'href=&quot;')"/>
				</xsl:call-template>
			</xsl:when>
			<xsl:when test="contains($path, '/')">
				<xsl:value-of select="substring-before($path, '/')"/>
				<xsl:text>/</xsl:text>
				<xsl:call-template name="getBase">
					<xsl:with-param name="path" select="substring-after($path, '/')"/>
				</xsl:call-template>
			</xsl:when>
		</xsl:choose>
	</xsl:template>

<!-- Could be overided, default behavior of this transform is to embed CSS -->
	<xsl:template name="css">
		<xsl:choose>
			<!-- if a css link is provide as a param -->
			<xsl:when test="normalize-space($css) != ''">
				<link rel="stylesheet" type="text/css" href="{$css}"/>
				<!-- formatting xml -->
				<link rel="stylesheet" type="text/css" href="{$base}xml2html.css"/>
			</xsl:when>
			<!-- if not, embed the one in the pack -->
			<xsl:otherwise>
				<style type="text/css">
					<!-- only way to work with firefox  -->
					<xsl:value-of select="document('xml2html.css')//comment()"/>
					<xsl:value-of select="document('html.css')//comment()"/>
				</style>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

  <!-- pour les éléments inconnus -->
  <xsl:template match="*" priority="-4">
    <font color="red">&lt;<xsl:value-of select="name()"/>&gt;</font>
      <xsl:apply-templates select="node()"/>
    <font color="red">&lt;/<xsl:value-of select="name()"/>&gt;</font>
  </xsl:template>

</xsl:transform>
