﻿<?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 $:
-->
<!--
Cette transformation importe eac2html.xsl
elle est appelée en contexte php pour vérifier les liens

réécrire les liens vers les instruments EAD
en créant une requête ?
réécrire les liens vers les notices EAC
-->
<xsl:transform version="1.1"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:php="http://php.net/xsl"
  exclude-result-prefixes="php"
>
  <!-- XSLT à importer pour le XML traité -->
  <xsl:import href="eac2html.xsl"/>
  <xsl:output  indent="yes" method="xml" encoding="UTF-8"/>
  <!-- lien entre notices EAC -->
  <xsl:template match="eacrel/@syskey">
    <xsl:attribute name="href">
      <xsl:choose>
        <xsl:when test="contains(., '.xml')">
          <xsl:text>?id=</xsl:text>
          <xsl:value-of select="substring-before(., '.xml')"/>
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of select="."/>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:attribute>
  </xsl:template>
  <!-- Liens vers un instrument EAD (pour l'instant débranché, il faut trouver une manière de tester)
  à voir
  -->
  <xsl:template match="resourcerel/@syskey">
	<xsl:attribute name="title">accéder à l'inventaire en ligne</xsl:attribute>
    <xsl:attribute name="href">
      <xsl:text>../ir.php?ir=</xsl:text>
      <xsl:value-of select="substring-before(concat(., '.xml'), '.xml')"/>
	  <xsl:choose>
		<!-- Recherche par authfilenumber -->
	  	<xsl:when test="$afn != ''">
			<xsl:text>&amp;referer=nominatif&amp;q=&amp;persname_authfilenumber=</xsl:text>
			<xsl:value-of select="$afn" />
		</xsl:when>
		<!-- Recherche plein texte sur le premier mot du nom -->
		<xsl:otherwise>
			<xsl:text>&amp;q=</xsl:text>
			<xsl:value-of select="substring-before(concat(ancestor::eac//part[@type='nom'], ' '), ' ')"/>
		</xsl:otherwise>
	  </xsl:choose>
    </xsl:attribute>
    <xsl:attribute name="onclick">if (window.opener &amp;&amp; this.href) {
   window.opener.focus(); window.opener.location.href=this.href; return false;
    }</xsl:attribute>
  </xsl:template>

</xsl:transform>
