<?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 $:

-->
<!--
XML EAC Encoded Archival Context
<http://jefferson.village.virginia.edu/eac>

Transformation vers HTML.
-->
<xsl:transform
  version="1.1"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
  exclude-result-prefixes="rdf rdfs"
>
  <!-- [PDI] On récupère dans une longue chaine, la liste des inventaires publics
    sous la forme : "FRANOM_00019.xml,FRANOM_00010.xml,..." -->
  <xsl:param name="publicirs" />

  <!-- [PDI] On passe ici le authfilenumber (il peut être vide, dans
       ce cas, on l'ignore. -->
  <xsl:param name="afn" />

  <!-- la déclaration de sortie -->
  <xsl:output method="xml" indent="yes" encoding="UTF-8" omit-xml-declaration="yes"/>
  <!-- chemin de schéma du type de document  -->
  <xsl:variable name="schema">eac.rdfs</xsl:variable>
  <!--
  charger le fichier descriptif des propriétés, dans le même dossier que l'XSLT
  -->
  <xsl:variable name="rdf:Property" select="document($schema, document(''))/*/rdf:Property"/>
  <!-- fabriquer le titre -->
  <xsl:variable name="title">
    <xsl:call-template name="title"/>
  </xsl:variable>

  <!-- noeud racine -->
  <xsl:template match="eac">
    <div class="eac">
      <table class="eac" summary="EAC">
        <caption class="title">
          <xsl:call-template name="title"/>
        </caption>
        <colgroup width="20%"/>
        <xsl:apply-templates/>
      </table>
    </div>
  </xsl:template>

  <!-- a priori, pas de raison de sortir le bloc identity -->
  <xsl:template match="identity"/>

  <!-- Rechercher un titre
part[@type='fullname'][1]
ne marche pas quand il y a 2 noms
-->
  <xsl:template name="title">
    <xsl:apply-templates select="condesc/identity" mode="title"/>
  </xsl:template>

  <!-- extraction du nom -->
  <xsl:template match="identity |  persgrp | corpgrp | famgrp" mode="title">
    <xsl:choose>
      <xsl:when test="pershead[@authorized]">
        <xsl:apply-templates select="pershead[@authorized][1]" mode="title"/>
      </xsl:when>
      <xsl:when test="corphead[@authorized]">
        <xsl:apply-templates select="corphead[@authorized][1]" mode="title"/>
      </xsl:when>
      <xsl:when test="famhead[@authorized]">
        <xsl:apply-templates select="famhead[@authorized][1]" mode="title"/>
      </xsl:when>
      <xsl:when test="pershead">
        <xsl:apply-templates select="pershead[1]" mode="title"/>
      </xsl:when>
      <xsl:when test="corphead">
        <xsl:apply-templates select="corphead[1]" mode="title"/>
      </xsl:when>
      <xsl:when test="famhead">
        <xsl:apply-templates select="famhead[1]" mode="title"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:apply-templates select="persgrp | corpgrp | famgrp" mode="title"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
  <xsl:template match="pershead | corphead | famhead" mode="title">
    <xsl:choose>
      <xsl:when test="part[contains(@type, 'full')]">
        <xsl:apply-templates select="part[contains(@type, 'full')]"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:apply-templates/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>


  <xsl:template match="eacheader">
  <!--
    <tfoot>
      <xsl:apply-templates select="@*"/>
      <tr>
        <th colspan="2" class="caption" align="left">
          <xsl:call-template name="label"/>
        </th>
      </tr>
      <xsl:apply-templates/>
    </tfoot>
  -->
  </xsl:template>

  <xsl:template match="condesc">
    <tbody class="condesc">
      <xsl:apply-templates select="@*|node()"/>
    </tbody>
  </xsl:template>

  <!--
  Passer à travers
  -->
  <xsl:template match="corpdesc | persdesc | famdesc">
    <xsl:apply-templates/>
  </xsl:template>
  <!--
  Conteneur des dates
<!ELEMENT existdesc
   ((existdate, place?)*, (descnote| sourceref)*)
  -->
  <xsl:template match="existdesc" priority="3">
    <tr class="existdesc">
      <xsl:apply-templates select="@*"/>
      <th class="label">
        <xsl:call-template name="label"/>
      </th>
      <td class="value">
        <xsl:call-template name="existdate"/>
        <xsl:apply-templates select="descnote| sourceref"/>
      </td>
    </tr>
  </xsl:template>

  <!-- template appelable pour une description texte -->
  <xsl:template name="existdate">
    <xsl:for-each select="existdate">
      <div class="existdate">
        <xsl:choose>
          <xsl:when test="contains(@type, 'naissance')">
            <xsl:call-template name="label">
              <xsl:with-param name="id" select="'birth'"/>
            </xsl:call-template>
            <xsl:text>&#160;: </xsl:text>
          </xsl:when>
          <xsl:when test="contains(@type, 'deces')">
            <xsl:call-template name="label">
              <xsl:with-param name="id" select="'death'"/>
            </xsl:call-template>
            <xsl:text>&#160;: </xsl:text>
          </xsl:when>
        </xsl:choose>
        <xsl:value-of select="normalize-space(.)"/>
        <xsl:if test="local-name(following-sibling::*[1]) = 'place'">
          <xsl:text> (</xsl:text>
          <xsl:value-of select="normalize-space(following-sibling::*[1])"/>
          <xsl:text>)</xsl:text>
        </xsl:if>
      </div>
    </xsl:for-each>
  </xsl:template>


  <!-- blocs à listes -->
  <xsl:template match="resourcerels | funactrels | ruledecl">
    <tr class="{local-name()} rels">
      <th class="label">
        <xsl:call-template name="label"/>
      </th>
      <td class="value {local-name()}">
        <xsl:apply-templates select="@*"/>
        <xsl:apply-templates select="head"/>
        <ul>
          <xsl:apply-templates select="resourcerel | funactrel | rule"/>
        </ul>
        <xsl:apply-templates select=" sourceref | sourcerefs | descnote | descnotes"/>
      </td>
    </tr>
  </xsl:template>
  <!-- item  -->
  <xsl:template match="rule | resourcerel | funactrel | eacrel">
    <li class="{local-name()}">
      <!-- ne pas appliquer ici l'attribut de lien, mais par dessous -->
      <xsl:apply-templates select="@*[@name != 'syskey'] | node()"/>
    </li>
  </xsl:template>
  <!-- lien vers une autre ressource -->
  <xsl:template match="bibunit | archunit | musunit | funactrel/funact ">
	<!-- [PDI] Gestion des liens à ne pas montrer car pointant vers des inventaires non publics -->
	<xsl:choose>
		<!-- Le cas où l'inventaire visé n'est pas public -->
		<xsl:when test="../@syskey and not(contains($publicirs, ../@syskey))">
			<xsl:value-of select="normalize-space(.)"/>
		</xsl:when>
		<!-- Cas normal -->
		<xsl:otherwise>
			<a class="{local-name()}">
			  <xsl:apply-templates select="@*"/>
			  <xsl:apply-templates select="../@syskey"/>
			  <xsl:value-of select="normalize-space(.)"/>
			</a>
		</xsl:otherwise>
	</xsl:choose>
  </xsl:template>

  <xsl:template match="eacrel/persname | eacrel/corpname | eacrel/famname">
    <a class="{local-name()}">
      <xsl:apply-templates select="@*"/>
      <!-- attention, ce test peut envoyer un warning avec certains processeur XSLT,
      permet de vérifier si la cible existe avant de créer le lien -->
      <xsl:choose>
        <xsl:when test="document(../@syskey)">
          <xsl:apply-templates select="../@syskey"/>
        </xsl:when>
        <xsl:otherwise>
          <xsl:attribute name="class">
            <xsl:value-of select="local-name()"/>
            <xsl:text> no</xsl:text>
          </xsl:attribute>
        </xsl:otherwise>
      </xsl:choose>
      <xsl:value-of select="normalize-space(.)"/>
    </a>
  </xsl:template>

  <xsl:template match="mainhist">
    <tr class="{local-name()}">
      <th class="label">
        <xsl:call-template name="label"/>
      </th>
      <td class="value">
        <table class="inline {local-name()}" summary="valeur">
          <xsl:apply-templates select="@*"/>
          <thead>
            <tr>
              <th>
                <xsl:call-template name="label">
                  <xsl:with-param name="id" select="'maintype'"/>
                </xsl:call-template>
              </th>
              <th>
                <xsl:call-template name="label">
                  <xsl:with-param name="id" select="'maindate'"/>
                </xsl:call-template>
              </th>
              <th>
                <xsl:call-template name="label">
                  <xsl:with-param name="id" select="'name'"/>
                </xsl:call-template>
              </th>
              <th>
                <xsl:call-template name="label">
                  <xsl:with-param name="id" select="'maindesc'"/>
                </xsl:call-template>
              </th>
            </tr>
          </thead>
          <tbody>
            <xsl:apply-templates select="mainevent"/>
          </tbody>
        </table>
      </td>
    </tr>
  </xsl:template>
  <xsl:template match="mainevent">
    <tr>
      <td>
        <xsl:call-template name="label">
          <xsl:with-param name="id" select="@maintype"/>
        </xsl:call-template>
      </td>
      <td>
        <xsl:apply-templates select="maindate"/>
      </td>
      <td>
        <xsl:apply-templates select="name"/>
      </td>
      <td>
        <xsl:apply-templates select="maindesc"/>
      </td>
    </tr>
  </xsl:template>

  <xsl:template match="desc">
    <xsl:apply-templates/>
  </xsl:template>

  <!-- ligne, eacheader/* -->
  <xsl:template match="bioghist | ocd | eacid |  languagedecl | sourcedecl | authdecl | corpdesc/* | persdesc/* | famdesc/* ">
    <tr class="{local-name()}">
      <xsl:apply-templates select="@*"/>
      <th class="label">
          <xsl:call-template name="label"/>
      </th>
      <td class="value">
        <xsl:apply-templates/>
      </td>
    </tr>
  </xsl:template>

  <xsl:template match="ocd/ocd">
    <div class="ocd">
      <xsl:apply-templates select="@*|node()"/>
    </div>
  </xsl:template>

  <!-- Intitulé d'un élément EAC -->
  <xsl:template name="label">
    <xsl:param name="id" select="local-name()"/>
    <xsl:choose>
      <xsl:when test="normalize-space($id) != ''">
        <xsl:copy-of select="$rdf:Property[@xml:id= $id][1]/rdfs:label[1]/node()"/>
      </xsl:when>
      <xsl:when test="normalize-space(@label) != ''">
        <xsl:value-of select="@label"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:copy-of select="$rdf:Property[@xml:id= local-name(current())][1]/rdfs:label[1]/node()"/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
  <!-- traiter les éléments du schéma ? -->

  <xsl:template match="chronlist">
    <div class="chronlist">
      <xsl:apply-templates select="head | chronhead"/>
      <ul>
        <xsl:apply-templates select="chronitem"/>
      </ul>
    </div>
  </xsl:template>

  <xsl:template match="chronhead | listhead">
    <xsl:apply-templates/>
  </xsl:template>

  <xsl:template match="chronitem">
    <li>
      <xsl:apply-templates select="event | eventgroup"/>
      <xsl:if test="place[normalize-space(.) != '']">, </xsl:if>
      <xsl:apply-templates select="place[normalize-space(.) != '']"/>
      <xsl:if test="date[normalize-space(.) != '']">, </xsl:if>
      <xsl:apply-templates select="date[normalize-space(.) != '']"/>
    </li>
  </xsl:template>

  <!--
événements
Pas de présentation tabulaire pour IREL
-->
  <!-- xsl:template match="chronlist">
    <xsl:param name="place" select="chronitem/place[normalize-space(.) != '']"/>
    <div class="chronlist">
      <table class="inline chronlist">
        <thead>
          <tr>
            <th>
              <xsl:call-template name="label">
                <xsl:with-param name="id" select="'date'"/>
              </xsl:call-template>
            </th>
            <xsl:if test="$place">
              <th>
                <xsl:call-template name="label">
                  <xsl:with-param name="id" select="'place'"/>
                </xsl:call-template>
              </th>
            </xsl:if>
            <th>
              <xsl:call-template name="label">
                <xsl:with-param name="id" select="'event'"/>
              </xsl:call-template>
            </th>
          </tr>
        </thead>
        <tbody>
          <xsl:for-each select="chronitem">
            <tr>
              <xsl:attribute name="class">
                <xsl:if test="position() = 1">first </xsl:if>
                <xsl:choose>
                  <xsl:when test="(position() mod 2) = 1">impair</xsl:when>
                  <xsl:otherwise>pair</xsl:otherwise>
                </xsl:choose>
              </xsl:attribute>
              <td>
                <xsl:apply-templates select="date"/>
              </td>
              <xsl:if test="$place">
                <td>
                  <xsl:apply-templates select="place"/>
                </td>
              </xsl:if>
              <td>
                <xsl:apply-templates select="event | eventgrp"/>
              </td>
            </tr>
          </xsl:for-each>
        </tbody>
      </table>
    </div>
  </xsl:template -->


  <xsl:template match="event">
    <span class="event">
      <!-- hck pour des problèmes d'espacements après indentation automatique -->
      <xsl:choose>
        <!-- un noeud texte non vide, texte mêlé -->
        <xsl:when test="text()[normalize-space(.) != '']">
          <xsl:apply-templates/>
        </xsl:when>
        <xsl:when test="*[2]">
          <xsl:apply-templates/>
        </xsl:when>
        <xsl:otherwise>
          <xsl:apply-templates select="*"/>
        </xsl:otherwise>
      </xsl:choose>
    </span>
  </xsl:template>
  <!-- pour un problème de saut de ligne dans les <event> -->
  <xsl:template match="event[not(text()[normalize-space(.) != ''])]/text()"/>


  <!-- Les relations à d'autres notices
  (head?, eacrel+,
    (sourceref | sourcerefs)?, (descnote | descnotes)? )
  -->
  <xsl:template match="eacrels">
    <xsl:apply-templates select="head"/>
    <xsl:variable name="ordre"> superior subordinate earlier later associative parent child identity </xsl:variable>
    <xsl:call-template name="reltype">
      <xsl:with-param name="ordre" select="$ordre"/>
    </xsl:call-template>
    <xsl:if test="sourceref | sourcerefs | descnote | descnotes">
      <tr class="eacrels rels">
        <th/>
        <td>
          <xsl:apply-templates select="sourceref | sourcerefs | descnote | descnotes"/>
        </td>
      </tr>
    </xsl:if>
  </xsl:template>

  <!-- à vérifier -->
  <xsl:template match="condesc/head | persdesc/head | famdesc/head | desc/head">
    <tr>
      <th class="head" colspan="2">
        <xsl:apply-templates select="@* | node()"/>
      </th>
    </tr>
  </xsl:template>
  <xsl:template match="head">
    <h4>
      <xsl:apply-templates select="@* | node()"/>
    </h4>
  </xsl:template>
  <xsl:template match="table/head">
    <caption>
      <xsl:apply-templates select="@* | node()"/>
    </caption>
  </xsl:template>



  <!-- traitement des attributs -->
  <xsl:template match="@*" priority="-1"/>
  <!-- surcharger la réécriture de liens dans un autre système -->
  <xsl:template match="@syskey | @href">
    <xsl:attribute name="href">
      <xsl:value-of select="."/>
    </xsl:attribute>
  </xsl:template>
  <xsl:template match="@align | @valign | @title">
    <xsl:attribute name="{local-name()}">
      <xsl:value-of select="."/>
    </xsl:attribute>
  </xsl:template>
  <xsl:template match="@type">
    <xsl:attribute name="class">
      <xsl:value-of select="translate(., ' -:;,_', '------')"/>
      <xsl:text> </xsl:text>
      <xsl:value-of select="local-name()"/>
    </xsl:attribute>
  </xsl:template>



        <!-- mise en ordre des relations
        reltype              (superior | subordinate | earlier |
                         later | associative | parent |
                         child | identity)

      <eacrel reltype="earlier" syskey="FRDAFANOM_EACP000018.xml">
        <persname>Nozières, Vital Auguste de Grégoire (1772/1776)</persname>
        <descnote>Gouverneur général de la Martinique<date normal="1772" type="date_relation">1172</date></descnote>
      </eacrel>

        -->
  <xsl:template name="reltype">
    <xsl:param name="ordre"/>
    <xsl:param name="reltype" select="normalize-space(substring-before($ordre, ' '))"/>
    <xsl:choose>
      <!-- fin de liste, les relations sans types -->
      <xsl:when test="normalize-space($ordre) = ''">
        <xsl:if test="eacrel[normalize-space(@reltype) = '' ]">
          <tr class="eacrels rels">
            <th class="label">
              <xsl:call-template name="label">
                <xsl:with-param name="id" select="'reltype'"/>
              </xsl:call-template>
            </th>
            <td class="value">
              <ul>
                <xsl:apply-templates select="eacrel[normalize-space(@reltype) = '' ]"/>
              </ul>
            </td>
          </tr>
        </xsl:if>
      </xsl:when>
      <!-- normaliser le séparateur -->
      <xsl:when test="$reltype = ''">
        <xsl:call-template name="reltype">
          <xsl:with-param name="ordre" select="normalize-space(substring-after($ordre, ' '))"/>
        </xsl:call-template>
      </xsl:when>
      <xsl:otherwise>
        <xsl:if test="eacrel[normalize-space(@reltype) = $reltype ]">
          <tr class="eacrels rels">
            <th class="label">
              <xsl:call-template name="label">
                <xsl:with-param name="id" select="concat('reltype-', $reltype)"/>
              </xsl:call-template>
            </th>
            <td class="value">
              <ul>
                <xsl:apply-templates select="eacrel[normalize-space(@reltype) = $reltype ]"/>
              </ul>
            </td>
          </tr>
        </xsl:if>
        <xsl:call-template name="reltype">
          <xsl:with-param name="ordre" select="normalize-space(substring-after($ordre, ' '))"/>
        </xsl:call-template>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <!-- structuration du texte -->
  <xsl:template match="lb">
    <br/>
  </xsl:template>
  <!--  liens -->
  <xsl:template match="  ptr | ref | didentifier | title | extptr | extref | archref | bibref | source">
    <a>
      <xsl:apply-templates select="@*"/>
      <xsl:value-of select="normalize-space(.)"/>
    </a>
  </xsl:template>
  <!-- inline générique -->
  <xsl:template match="date | maindate | num | place | emph | abbr | expan | edition | imprint | bibseries | descnote | language">
    <span class="{local-name()}">
      <xsl:apply-templates select="@*|node()"/>
    </span>
  </xsl:template>
  <xsl:template match="title">
    <em class="{local-name()}">
      <xsl:apply-templates select="@*|node()"/>
    </em>
  </xsl:template>
  <!-- termes d'indexation -->
  <xsl:template match="subject | genreform | funact">
    <span class="{local-name()} term">
      <xsl:apply-templates select="@*|node()"/>
    </span>
  </xsl:template>
  <!-- les noms -->
  <xsl:template match="name | corpname | famname | persname">
    <acronym class="{local-name()}">
      <xsl:apply-templates select="@*|node()"/>
    </acronym>
  </xsl:template>
  <!-- des blocs -->
  <xsl:template match="maindesc">
    <div class="{local-name()}">
      <xsl:apply-templates select="@*|node()"/>
    </div>
  </xsl:template>
  <xsl:template match="blockquote">
    <blockquote>
      <xsl:apply-templates/>
    </blockquote>
  </xsl:template>
  <xsl:template match="address">
    <address>
      <xsl:apply-templates/>
    </address>
  </xsl:template>
  <xsl:template match="table">
    <table summary="pour la mise en forme">
      <xsl:apply-templates/>
    </table>
  </xsl:template>
  <!--
  <!ELEMENT list
   (head?, (item+ | (listhead?, items+)))
                                                                             >
<!ATTLIST list
   %a.common;
   type                 (simple | deflist | marked | ordered)   #IMPLIED
   mark               	CDATA                                   #IMPLIED
   numeration           (arabic | upperalpha | loweralpha |
                          upperroman | lowerroman)              #IMPLIED
   continuation         (continues | starts)                    #IMPLIED
                                                                             >
-->
  <xsl:template match="list">
    <div class="list">
      <xsl:apply-templates select="@*"/>
      <xsl:apply-templates select="head | listhead"/>
      <ul>
        <xsl:apply-templates select="items | item"/>
      </ul>
    </div>
  </xsl:template>
  <xsl:template match="list">
    <div class="list">
      <xsl:apply-templates select="head | listhead"/>
      <xsl:choose>
        <xsl:when test="@type = 'marked'">
          <ul>
            <xsl:apply-templates select="@*"/>
            <xsl:apply-templates select="item"/>
          </ul>
        </xsl:when>
        <xsl:when test="@type = 'ordered'">
          <ol>
            <xsl:apply-templates select="@*"/>
            <xsl:apply-templates select="item"/>
          </ol>
        </xsl:when>
        <xsl:otherwise>
          <ul>
            <xsl:apply-templates select="@*"/>
            <xsl:apply-templates select="item"/>
          </ul>
        </xsl:otherwise>
      </xsl:choose>
    </div>
  </xsl:template>
  <xsl:template match="item">
    <li>
      <xsl:apply-templates select="@*|node()"/>
    </li>
  </xsl:template>

  <xsl:template match="list[items]">
    <div class="list">
      <xsl:apply-templates select="@*"/>
      <xsl:apply-templates select="head | listhead"/>
      <dl>
        <xsl:apply-templates select="items"/>
      </dl>
    </div>
  </xsl:template>
  <xsl:template match="items">
    <dt>
      <xsl:apply-templates select="item[1]/@* | item[1]/node()"/>
    </dt>
    <dd>
      <xsl:apply-templates select="item[2]/@* | item[2]/node()"/>
    </dd>
  </xsl:template>
  <xsl:template match="p">
	<xsl:if test="normalize-space(.) != ''">
		<p>
		  <xsl:apply-templates/>
		</p>
	</xsl:if>
  </xsl:template>
  <xsl:template match="head01">
    <h1>
      <xsl:apply-templates/>
    </h1>
  </xsl:template>
  <xsl:template match="head02">
    <h2>
      <xsl:apply-templates/>
    </h2>
  </xsl:template>
  <xsl:template match="head03">
    <h3>
      <xsl:apply-templates/>
    </h3>
  </xsl:template>
  <!-- avec attribut @render
"bold" | "italic" | "bolditalic" | "boldunderline" | "boldsmcaps" | "boldquoted" | "nonproport" | "altrender" | "quoted" | "smcaps" | "sub" | "super" | "underline"
-->
  <xsl:template match="*[normalize-space(@render) != '']">
    <xsl:choose>
      <xsl:when test="@render = 'bold'">
        <b class="{local-name()}">
          <xsl:apply-templates select="node() | @*"/>
        </b>
      </xsl:when>
      <xsl:when test="@render = 'italic'">
        <i class="{local-name()}">
          <xsl:apply-templates select="node() | @*"/>
        </i>
      </xsl:when>
      <xsl:when test="@render = 'sub'">
        <sub class="{local-name()}">
          <xsl:apply-templates select="node() | @*"/>
        </sub>
      </xsl:when>
      <xsl:when test="@render = 'super'">
        <sup class="{local-name()}">
          <xsl:apply-templates select="node() | @*"/>
        </sup>
      </xsl:when>
      <xsl:when test="@render = 'underline'">
        <u class="{local-name()}">
          <xsl:apply-templates select="node() | @*"/>
        </u>
      </xsl:when>
      <xsl:when test="@render = 'quoted'">
        <q class="{local-name()}">
          <xsl:apply-templates select="node() | @*"/>
        </q>
      </xsl:when>
      <xsl:when test="@render = 'smcaps'">
        <acronym class="{local-name()}">
          <xsl:apply-templates select="node() | @*"/>
        </acronym>
      </xsl:when>
      <xsl:when test="@render = 'bolditalic'">
        <b class="{local-name()}">
          <i class="{local-name()}">
            <xsl:apply-templates select="node() | @*"/>
          </i>
        </b>
      </xsl:when>
      <xsl:when test="@render = 'boldunderline'">
        <b class="{local-name()}">
          <u class="{local-name()}">
            <xsl:apply-templates select="node() | @*"/>
          </u>
        </b>
      </xsl:when>
      <xsl:when test="@render = 'boldquoted'">
        <b class="{local-name()}">
          <q class="{local-name()}">
            <xsl:apply-templates select="node() | @*"/>
          </q>
        </b>
      </xsl:when>
      <xsl:otherwise>
        <span class="{@render} {local-name()}">
          <xsl:apply-templates select="node() | @*"/>
        </span>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

</xsl:transform>
