Newer
Older
ade-outils-xml / xslt / Wileyml3g.xsl
@niederle niederle on 29 Dec 2015 274 KB 1er commit
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:a1="http://www.wiley.com/namespaces/wiley" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" exclude-result-prefixes="a1">
    <xsl:output encoding="UTF-8" indent="no" omit-xml-declaration="yes"/>
    <xsl:param name="idistex"/>
    <xsl:param name="datecreation"/>
    <!-- Feuille de style ISTEX Editeur WILEY (Wileyml3gv102-flat.dtd)
        =======================================================================================
        Auteur:  Stéphanie GREGORIO - INIST/CNRS
        =======================================================================================
        Version 0.2 du 03/04/2014
        Version 0.3 du 08/01/2015 reprise feuille, affiliations multiples
        Version 0.4 du 26/01/2015 ajout code iso: rfc3066 (2 caracteres) ou iso639-2b (3 caracteres) en attente de validation + xml:lang
        Version 0.5 du 19/03/2015
        Version 0.6 du 10/04/2015 nettoyage du fichier en entrée (caracteres)
        Version 0.6.1 du 16/04/2015 (bug fixé ligne 1073)
        Version 0.6.2 du 03/07/2015 (pagination/relatedItem)
        Version 0.6.3 du 06/07/2015 (reprise bloc titres langues)
        Version 0.6.4 du 17/09/2015 (extent (figures/words/ref/tables) sous physicalDescription suite réunion groupe MODS 14/09/2015)
        Version 0.6.5 du 15/10/2015 (reprise langue titre + articleCategory)
        Version 0.6.6 du 02/11/2015 (reprise abstract (p))
        Version 0.6.6.1 du 06/11/2015 (reprise categories)
        Version 0.7 du 03/12/2015 (normalisation article categories)
    -->
    <!-- ASPECTS  FONCTIONNELS : -->
    <!-- reformatage des données WILEY vers MODS XSD MODS.v.3.6 -->
    <xsl:variable name="cptCreator">
        <xsl:value-of select="count(//a1:creator)"/>
    </xsl:variable>
    <xsl:variable name="lang">
        <xsl:value-of select="//a1:component/@xml:lang"/>
    </xsl:variable>
    <!-- Traitement Principal -->
    <xsl:template match="text()">
        <!--
            tabulation horizontale &#9; \t
            changement de ligne &#10; \n
            retour chariot &#13;  \r
            a la ligne &#133;
            separateur de ligne &#8232;
            séparateur de paragraphe &#8233;
        -->
        <xsl:value-of select="translate(.,'&#9;&#13;&#10;&#133;&#8232;&#8233;&#8234;&#8235;&#8236;&#8237;','')"/>
    </xsl:template>
    <xsl:template match="a1:p">
        <xsl:value-of select="concat(' ',.,' ')"/>
    </xsl:template>
    <xsl:template match="a1:abstract/a1:title"/>
    <xsl:template match="a1:label"/>
    <xsl:template match="a1:link"/>
    <xsl:template match="a1:section/a1:title"><xsl:value-of select="concat(' ',.,': ')"/></xsl:template>
    <xsl:template match="/">
        <xsl:comment>
            <xsl:text>Version 0.6 générée le </xsl:text>
            <xsl:value-of select="$datecreation"/>
        </xsl:comment>
        <mods xmlns="http://www.loc.gov/mods/v3">
            <xsl:attribute name="version">
                <xsl:text>3.6</xsl:text>
            </xsl:attribute>
            <xsl:choose>
                <xsl:when test="not(//a1:component/a1:header/a1:contentMeta/a1:titleGroup/a1:title/a1:citation)">
                    <xsl:for-each select="//a1:contentMeta/a1:titleGroup/a1:title[@type='main']">
                        <titleInfo xmlns="http://www.loc.gov/mods/v3">
                            
                             <xsl:choose>
                                 <xsl:when test="@xml:lang">
                                     <xsl:attribute name="lang">
                                         <xsl:value-of select="translate(@xml:lang,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')"/>
                                     </xsl:attribute>
                                 </xsl:when>
                                 <xsl:otherwise>
                                     <xsl:attribute name="lang">
                                         <xsl:value-of select="//a1:component/@xml:lang"/>
                                     </xsl:attribute>
                                 </xsl:otherwise>
                             </xsl:choose>
                            <title xmlns="http://www.loc.gov/mods/v3">
                                <xsl:variable name="ttl">
                                    <xsl:apply-templates select="."/>
                                </xsl:variable>
                                <xsl:value-of select="normalize-space($ttl)"/>
                            </title>
                            <xsl:if test="//a1:contentMeta/a1:titleGroup/a1:title[@type='subtitle'][string-length()&gt;0]">
                                <xsl:call-template name="subTitle"/>
                            </xsl:if>
                        </titleInfo>
                    </xsl:for-each>
                </xsl:when>
            </xsl:choose>
            <xsl:if test="not(//a1:component/a1:header/a1:contentMeta/a1:titleGroup/a1:title[@type='main']) and //a1:component/a1:header/a1:contentMeta/a1:titleGroup/a1:title[@type='tocForm'][string-length()&gt;0]">
                <xsl:for-each select="//a1:contentMeta/a1:titleGroup/a1:title[@type='tocForm']">
                <titleInfo xmlns="http://www.loc.gov/mods/v3">
                    
                    <xsl:if test="@xml:lang[string-length()&gt;0]">
                        <xsl:attribute name="lang">
                            <xsl:value-of select="translate(@xml:lang,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')"/>
                        </xsl:attribute>
                    </xsl:if>
                    <title xmlns="http://www.loc.gov/mods/v3">
                        <xsl:variable name="ttl">
                            <xsl:apply-templates select="."/>
                        </xsl:variable>
                        <xsl:value-of select="normalize-space($ttl)"/>
                    </title>
                </titleInfo>
                    </xsl:for-each>
            </xsl:if>
            <xsl:choose>
                <xsl:when test="//a1:component/a1:header/a1:contentMeta/a1:titleGroup/a1:title[@type='short']">
                    <titleInfo xmlns="http://www.loc.gov/mods/v3">
                        <xsl:attribute name="type">
                            <xsl:text>abbreviated</xsl:text>
                        </xsl:attribute>
                        <xsl:if test="//a1:component/a1:header/a1:contentMeta/a1:titleGroup/a1:title[@type='short']/@xml:lang">
                            <xsl:attribute name="lang">
                                <xsl:value-of select="translate(//a1:component/a1:header/a1:contentMeta/a1:titleGroup/a1:title[@type='short']/@xml:lang,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')"/>
                            </xsl:attribute>
                        </xsl:if>
                        <title xmlns="http://www.loc.gov/mods/v3">
                            <xsl:variable name="ttlsh">
                                <xsl:apply-templates select="//a1:component/a1:header/a1:contentMeta/a1:titleGroup/a1:title[@type='short']"></xsl:apply-templates>
                            </xsl:variable>
                            <xsl:value-of select="normalize-space($ttlsh)"/>
                        </title>
                    </titleInfo>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:if test="//a1:publicationMeta[@type='article']/a1:titleGroup/a1:title[@type='short']">
                        <titleInfo xmlns="http://www.loc.gov/mods/v3">
                            <xsl:attribute name="type">
                                <xsl:text>abbreviated</xsl:text>
                            </xsl:attribute>
                            <xsl:if test="//a1:publicationMeta[@type='article']/a1:titleGroup/a1:title[@type='short']/@xml:lang">
                                <xsl:attribute name="lang">
                                    <xsl:value-of select="translate(//a1:publicationMeta[@type='article']/a1:titleGroup/a1:title[@type='short']/@xml:lang,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')"/>
                                </xsl:attribute>
                            </xsl:if>
                            <title xmlns="http://www.loc.gov/mods/v3">
                                <xsl:variable name="ttlsh">
                                    <xsl:apply-templates select="//a1:publicationMeta[@type='article']/a1:titleGroup/a1:title[@type='short']"></xsl:apply-templates>
                                </xsl:variable>
                                <xsl:value-of select="normalize-space($ttlsh)"/>
                            </title>
                        </titleInfo>
                    </xsl:if>
                </xsl:otherwise>
            </xsl:choose>
                <xsl:choose>
                    <xsl:when test="not(//a1:component/a1:header/a1:contentMeta/a1:titleGroup/a1:title[@type='subtitle']/@xml:lang=//a1:component/a1:header/a1:contentMeta/a1:titleGroup/a1:title[@type='main']/@xml:lang) and //a1:component/a1:header/a1:contentMeta/a1:titleGroup/a1:title[@type='subtitle']/@xml:lang ">
                        <xsl:for-each select="//a1:contentMeta/a1:titleGroup/a1:title[@type='subtitle']">
                        <titleInfo xmlns="http://www.loc.gov/mods/v3">
                                <xsl:attribute name="type">translated</xsl:attribute>
                                <xsl:if test="@xml:lang">
                                <xsl:attribute name="lang">
                                    <xsl:value-of select="translate(@xml:lang,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')"/>
                                </xsl:attribute>
                                </xsl:if>
                                <title xmlns="http://www.loc.gov/mods/v3">
                                    <xsl:variable name="ttl">
                                        <xsl:apply-templates select="."/>
                                    </xsl:variable>
                                    <xsl:value-of select="normalize-space($ttl)"/>
                            </title>
                        </titleInfo>
                            </xsl:for-each>
                        </xsl:when>
                    </xsl:choose>
                <!-- titre brut en cdata suite demande J. Ducloy janvier 2014-->
            <!-- <xsl:text disable-output-escaping="yes">&lt;![CDATA[</xsl:text>
                <xsl:text disable-output-escaping="yes">]]&gt;</xsl:text> -->
            <xsl:choose>
                <xsl:when test="not(//a1:component/a1:header/a1:contentMeta/a1:titleGroup/a1:title/a1:citation)">
                    <xsl:for-each select="//a1:contentMeta/a1:titleGroup/a1:title[@type='main']">
                        <titleInfo xmlns="http://www.loc.gov/mods/v3">
                            <xsl:attribute name="type">alternative</xsl:attribute>
                            <xsl:attribute name="contentType">
                                <xsl:text>CDATA</xsl:text>
                            </xsl:attribute>
                            <xsl:choose>
                                <xsl:when test="@xml:lang">
                                    <xsl:attribute name="lang">
                                        <xsl:value-of select="translate(@xml:lang,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')"/>
                                    </xsl:attribute>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:attribute name="lang">
                                        <xsl:value-of select="//a1:component/@xml:lang"/>
                                    </xsl:attribute>
                                </xsl:otherwise>
                            </xsl:choose>
                            <title xmlns="http://www.loc.gov/mods/v3">
                                <xsl:text disable-output-escaping="yes">&lt;![CDATA[</xsl:text>
                                <xsl:value-of select="normalize-space(./text())"/>
                                <xsl:text disable-output-escaping="yes">]]&gt;</xsl:text>
                            </title>
                        </titleInfo>
                    </xsl:for-each>
                </xsl:when>
            </xsl:choose>
                <xsl:choose>
                    <xsl:when test="not(//a1:component/a1:header/a1:contentMeta/a1:titleGroup/a1:title[@type='subtitle'][@xml:lang=//a1:component/a1:header/a1:contentMeta/a1:titleGroup/a1:title[@type='main']/@xml:lang]) and //a1:component/a1:header/a1:contentMeta/a1:titleGroup/a1:title[@type='subtitle']/@xml:lang ">
                        <titleInfo xmlns="http://www.loc.gov/mods/v3">
                            <xsl:attribute name="type">alternative</xsl:attribute>
                            <xsl:if test="//a1:contentMeta/a1:titleGroup/a1:title[@type='subtitle']/@xml:lang">
                                    <xsl:attribute name="lang">
                                        <xsl:value-of select="translate(//a1:contentMeta/a1:titleGroup/a1:title[@type='subtitle']/@xml:lang,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')"/>
                                    </xsl:attribute>
                            </xsl:if>
                            <xsl:attribute name="contentType">
                                <xsl:text>CDATA</xsl:text>
                            </xsl:attribute>
                            <title xmlns="http://www.loc.gov/mods/v3">
                                <xsl:text disable-output-escaping="yes">&lt;![CDATA[</xsl:text>
                                <xsl:value-of select="normalize-space(//a1:component/a1:header/a1:contentMeta/a1:titleGroup/a1:title[@type='subtitle'])"/>
                                <xsl:text disable-output-escaping="yes">]]&gt;</xsl:text>
                            </title>
                        </titleInfo>
                    </xsl:when>
                </xsl:choose>
            <!--  Traitement des auteurs et affils  -->
            <xsl:if test="//a1:contentMeta/a1:creators[string-length() &gt; 0]">
                <xsl:for-each select="//a1:contentMeta/a1:creators/a1:creator">
                    <xsl:choose>
                        <xsl:when test="a1:groupName">
                            <!-- corpauthor -->
                            <xsl:for-each select="a1:groupName">
                                <name xmlns="http://www.loc.gov/mods/v3">
                                    <xsl:attribute name="type">corporate</xsl:attribute>
                                    <namePart xmlns="http://www.loc.gov/mods/v3">
                                        <xsl:variable name="name">
                                            <xsl:apply-templates select="."/>
                                        </xsl:variable>
                                        <xsl:value-of select="normalize-space($name)"/>
                                    </namePart>
                                    <!-- Affiliation -->
                                    <xsl:if test="//a1:creator/@noteRef">
                                        <xsl:call-template name="affiliation"/>
                                    </xsl:if>
                                    <xsl:if test="//a1:affiliation/a1:unparsedAffiliation">
                                        <description xmlns="http://www.loc.gov/mods/v3">
                                            <xsl:variable name="dscr">
                                                <xsl:apply-templates select="//a1:affiliation/a1:unparsedAffiliation"/>
                                            </xsl:variable>
                                            <xsl:value-of select="normalize-space($dscr)"/>
                                        </description>
                                    </xsl:if>
                                </name>
                            </xsl:for-each>
                        </xsl:when>
                        <xsl:when test="normalize-space(a1:personName)">
                            <name xmlns="http://www.loc.gov/mods/v3">
                                <xsl:attribute name="type">personal</xsl:attribute>
                                <xsl:call-template name="name2"/>
                                <!-- EMAIL -->
                                <xsl:if test="a1:contactDetails/a1:email[string-length()&gt;0] and not(@corresponding='yes')">
                                    <xsl:for-each select="a1:contactDetails/a1:email">
                                        <affiliation xmlns="http://www.loc.gov/mods/v3">
                                            <xsl:text>E-mail: </xsl:text>
                                            <xsl:variable name="email">
                                                <xsl:apply-templates select="."/>
                                            </xsl:variable>
                                            <xsl:value-of select="normalize-space($email)"/>
                                        </affiliation>
                                    </xsl:for-each>
                                </xsl:if>
                                <!-- Affiliation -->
                                <xsl:if test="//a1:affiliationGroup">
                                   <xsl:call-template name="affiliation"/>
                                </xsl:if>
                                <!-- Affiliation corresp-->
                                <xsl:if test="@corresponding='yes'">
                                    <xsl:for-each select="//a1:publicationMeta/a1:correspondenceTo/a1:lineatedText">
                                        <affiliation xmlns="http://www.loc.gov/mods/v3">
                                            <xsl:variable name="corresp">
                                                <xsl:apply-templates select="a1:line/text()"/>
                                            </xsl:variable>
                                            <xsl:value-of select="normalize-space($corresp)"/>
                                        </affiliation>
                                        <xsl:if test="a1:line/a1:email">
                                            <affiliation xmlns="http://www.loc.gov/mods/v3">
                                                <xsl:text>E-mail: </xsl:text>
                                                <xsl:variable name="email">
                                                    <xsl:apply-templates select="a1:line/a1:email"/>
                                                </xsl:variable>
                                                <xsl:value-of select="normalize-space($email)"/>
                                            </affiliation>
                                        </xsl:if>
                                    </xsl:for-each>
                                </xsl:if>
                                <xsl:if test="@affiliationRef=@correspondenceRef and //a1:publicationMeta/a1:correspondenceTo/a1:lineatedText/a1:line[string-length()&gt;0]">
                                    <affiliation xmlns="http://www.loc.gov/mods/v3">
                                        <xsl:text>Correspondence: </xsl:text>
                                        <xsl:variable name="corresp">
                                            <xsl:apply-templates select="//a1:publicationMeta/a1:correspondenceTo/a1:lineatedText/a1:line"/>
                                        </xsl:variable>
                                        <xsl:value-of select="normalize-space($corresp)"/>
                                    </affiliation>
                                </xsl:if>
                                <!-- noteRef -->
                                <xsl:if test="@corresponding='yes' and not(//a1:component/a1:header/a1:publicationMeta/a1:correspondenceTo/@xml:id) and //a1:component/a1:header/a1:publicationMeta/a1:correspondenceTo[string-length() &gt; 0] and not (//a1:component/a1:header/a1:publicationMeta/a1:correspondenceTo/a1:lineatedText)">
                                    <xsl:for-each select="//a1:component/a1:header/a1:publicationMeta/a1:correspondenceTo">
                                        <description>
                                            <xsl:if test="not (contains(.,'Correspondence'))">
                                                <xsl:text>Correspondence: </xsl:text>
                                            </xsl:if>
                                            <xsl:variable name="corresp">
                                                <xsl:apply-templates select="./text()"/>
                                            </xsl:variable>
                                            <xsl:value-of select="$corresp"/>
                                        </description>
                                    </xsl:for-each>
                                </xsl:if>

                                <!-- traitement des roles -->
                                <xsl:if test="@creatorRole='author'">
                                    <role xmlns="http://www.loc.gov/mods/v3">
                                        <roleTerm xmlns="http://www.loc.gov/mods/v3">
                                            <xsl:attribute name="type">text</xsl:attribute>
                                            <xsl:text>author</xsl:text>
                                        </roleTerm>
                                    </role>
                                </xsl:if>
                                <xsl:if test="@creatorRole='editor'">
                                    <role xmlns="http://www.loc.gov/mods/v3">
                                        <roleTerm xmlns="http://www.loc.gov/mods/v3">
                                            <xsl:attribute name="type">text</xsl:attribute>
                                            <xsl:text>editor</xsl:text>
                                        </roleTerm>
                                    </role>
                                </xsl:if>
                                <xsl:if test="a1:jobTitle">
                                    <description xmlns="http://www.loc.gov/mods/v3">
                                        <xsl:variable name="jobTitle">
                                            <xsl:apply-templates select="a1:jobTitle"/>
                                        </xsl:variable>
                                        <xsl:value-of select="normalize-space($jobTitle)"/>
                                    </description>
                                </xsl:if>
                            </name>
                        </xsl:when>
                    </xsl:choose>
                </xsl:for-each>
            </xsl:if>
            <!--  typeOfRessource  -->
            <typeOfResource xmlns="http://www.loc.gov/mods/v3">
                <xsl:text>text</xsl:text>
            </typeOfResource>
            <!-- Genre     -->
            <xsl:variable name="codeGenre1">
                <xsl:value-of select="//a1:component/a1:header/a1:publicationMeta[@level='unit']/@type"/>
            </xsl:variable>
            <xsl:variable name="codeGenre">
                <xsl:choose>
                    <xsl:when test="normalize-space($codeGenre1)='article'">article</xsl:when>
                    <xsl:when test="normalize-space($codeGenre1)='reviewArticle'">review-article</xsl:when>
                    <xsl:when test="normalize-space($codeGenre1)='editorial'">editorial</xsl:when>
                    <xsl:when test="normalize-space($codeGenre1)='bookReview'">book reviews</xsl:when>
                    <xsl:when test="normalize-space($codeGenre1)='shortCommunication'">brief communication</xsl:when>
                    <xsl:when test="normalize-space($codeGenre1)='shortArticle'">article</xsl:when>
                    <xsl:when test="normalize-space($codeGenre1)='rapidCommunication'">brief communication</xsl:when>
                    <xsl:when test="normalize-space($codeGenre1)='caseStudy'">case report</xsl:when>
                    <xsl:when test="normalize-space($codeGenre1)='abstract'">abstract</xsl:when>
                    <xsl:otherwise>
                        <xsl:text>other</xsl:text>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:variable>
            <xsl:if test="//a1:component/a1:header/a1:publicationMeta[@level='unit']/@type[string-length()&gt; 0]">
                <genre xmlns="http://www.loc.gov/mods/v3">
                    <xsl:attribute name="type">
                        <xsl:value-of select="normalize-space($codeGenre)"/>
                    </xsl:attribute>
                    <xsl:value-of select="normalize-space($codeGenre1)"/>
                </genre>
            </xsl:if>
            
            <!-- OriginInfo -->
            <originInfo xmlns="http://www.loc.gov/mods/v3">
                <xsl:choose>
                    <xsl:when test="//a1:component/a1:header/a1:publicationMeta/a1:publisherInfo/a1:publisherName[string-length() &gt; 0]">
                        <publisher xmlns="http://www.loc.gov/mods/v3">
                            <xsl:variable name="pub">
                                <xsl:apply-templates select="//a1:component/a1:header/a1:publicationMeta/a1:publisherInfo/a1:publisherName"/>
                            </xsl:variable>
                            <xsl:value-of select="normalize-space($pub)"/>
                        </publisher>
                    </xsl:when>
                    <xsl:otherwise>
                        <publisher xmlns="http://www.loc.gov/mods/v3">
                            <xsl:text>Blackwell Publishing Ltd</xsl:text>
                        </publisher>
                    </xsl:otherwise>
                </xsl:choose>
                <xsl:if test="//a1:component/a1:header/a1:publicationMeta/a1:publisherInfo/a1:publisherLoc[string-length() &gt; 0]">
                    <place xmlns="http://www.loc.gov/mods/v3">
                        <placeTerm xmlns="http://www.loc.gov/mods/v3">
                            <xsl:attribute name="type">text</xsl:attribute>
                            <xsl:value-of select="normalize-space(//a1:component/a1:header/a1:publicationMeta/a1:publisherInfo/a1:publisherLoc)"/>
                        </placeTerm>
                    </place>
                </xsl:if>
                <xsl:choose>
                    <xsl:when test="//a1:component/a1:header/a1:publicationMeta/a1:coverDate/@startDate[string-length()&gt; 0]">
                        <dateIssued xmlns="http://www.loc.gov/mods/v3">
                            <xsl:attribute name="encoding">w3cdtf</xsl:attribute>
                            <xsl:apply-templates select="//a1:component/a1:header/a1:publicationMeta/a1:coverDate/@startDate"/>
                        </dateIssued>
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:if test="//a1:component/a1:header/a1:publicationMeta/a1:eventGroup/a1:event[@type='firstOnline']/@date[string-length()&gt; 0]">
                            <dateIssued xmlns="http://www.loc.gov/mods/v3">
                                <xsl:attribute name="encoding">w3cdtf</xsl:attribute>
                                <xsl:apply-templates select="//a1:component/a1:header/a1:publicationMeta/a1:eventGroup/a1:event[@type='firstOnline']/@date"/>
                            </dateIssued>
                        </xsl:if>
                    </xsl:otherwise>
                </xsl:choose>
                <xsl:if test="//a1:component/a1:header/a1:publicationMeta/a1:eventGroup/a1:event[@type='xmlCreated']/@date[string-length()&gt; 0]">
                    <dateCreated xmlns="http://www.loc.gov/mods/v3">
                        <xsl:attribute name="encoding">w3cdtf</xsl:attribute>
                        <xsl:apply-templates select="//a1:component/a1:header/a1:publicationMeta/a1:eventGroup/a1:event[@type='xmlCreated']/@date"/>
                    </dateCreated>
                </xsl:if>
                <xsl:if test="//a1:component/a1:header/a1:publicationMeta/a1:eventGroup/a1:event[@type='manuscriptReceived']/@date[string-length()&gt; 0]">
                    <dateCaptured xmlns="http://www.loc.gov/mods/v3">
                        <xsl:attribute name="encoding">w3cdtf</xsl:attribute>
                        <xsl:apply-templates select="//a1:component/a1:header/a1:publicationMeta/a1:eventGroup/a1:event[@type='manuscriptReceived']/@date"/>
                    </dateCaptured>
                </xsl:if>
                <xsl:if test="//a1:component/a1:header/a1:publicationMeta/a1:eventGroup/a1:event[@type='manuscriptAccepted']/@date[string-length()&gt; 0]">
                    <dateValid xmlns="http://www.loc.gov/mods/v3">
                        <xsl:attribute name="encoding">w3cdtf</xsl:attribute>
                        <xsl:apply-templates select="//a1:component/a1:header/a1:publicationMeta/a1:eventGroup/a1:event[@type='manuscriptAccepted']/@date"/>
                    </dateValid>
                </xsl:if>
                <xsl:if test="//a1:publicationMeta[@level='unit']/a1:selfCitationGroup/a1:citation[string-length() &gt; 0]">
                    <xsl:for-each select="//a1:publicationMeta[@level='unit']/a1:selfCitationGroup/a1:citation">
                        <edition>
                            <xsl:variable name="cit">
                                <xsl:apply-templates select="//a1:publicationMeta[@level='unit']/a1:selfCitationGroup/a1:citation"/>
                            </xsl:variable>
                            <xsl:value-of select="normalize-space($cit)"/>
                        </edition>
                    </xsl:for-each>
                </xsl:if>
                <xsl:if test="//a1:header/a1:contentMeta/a1:unparsedEditorialHistory[string-length() &gt; 0]">
                    <edition xmlns="http://www.loc.gov/mods/v3">
                        <xsl:variable name="norm">
                            <xsl:apply-templates select="//a1:header/a1:contentMeta/a1:unparsedEditorialHistory"/>
                        </xsl:variable>
                        <xsl:value-of select="normalize-space($norm)"/>
                    </edition>
                </xsl:if>
                <!-- date de copyright -->
                <xsl:if test="//a1:component/a1:header/a1:publicationMeta/a1:coverDate/@startDate[string-length() &gt; 0]">
                    <copyrightDate xmlns="http://www.loc.gov/mods/v3">
                        <xsl:attribute name="encoding">w3cdtf</xsl:attribute>
                        <xsl:choose>
                            <xsl:when test="contains(//a1:component/a1:header/a1:publicationMeta/a1:coverDate/@startDate,'-')">
                                <xsl:value-of select="substring-before(//a1:component/a1:header/a1:publicationMeta/a1:coverDate/@startDate,'-')"/>
                            </xsl:when>
                            <xsl:otherwise>
                                <xsl:apply-templates select="//a1:component/a1:header/a1:publicationMeta/a1:coverDate/@startDate"/>
                            </xsl:otherwise>
                        </xsl:choose>
                    </copyrightDate>
                </xsl:if>
            </originInfo>

            <!-- ******************* Language ******************************-->
            <xsl:if test="//a1:component/@xml:lang[string-length() &gt; 0] | //a1:component/a1:header/a1:contentMeta/a1:titleGroup/a1:title[@type='main']/@xml:lang[string-length()&gt; 0]">
                <xsl:choose>
                    <xsl:when test="//a1:component/a1:header/a1:contentMeta/a1:titleGroup/a1:title[@type='main']/@xml:lang[string-length() = 3]">
                        <language xmlns="http://www.loc.gov/mods/v3">
                            <xsl:choose>
                                <xsl:when test="//a1:component/a1:header/a1:contentMeta/a1:titleGroup/a1:title[@type='main']/@xml:lang[string-length() = 3]">
                                    <languageTerm xmlns="http://www.loc.gov/mods/v3">
                                        <xsl:attribute name="type">code</xsl:attribute>
                                        <xsl:attribute name="authority">iso639-2b</xsl:attribute>
                                        <xsl:value-of select="normalize-space(translate(//a1:component/a1:header/a1:contentMeta/a1:titleGroup/a1:title[@type='main']/@xml:lang,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz'))"/>
                                    </languageTerm>
                                </xsl:when>
                                <xsl:when test="//a1:component/@xml:lang[string-length() = 3]">
                                    <languageTerm xmlns="http://www.loc.gov/mods/v3">
                                        <xsl:attribute name="type">code</xsl:attribute>
                                        <xsl:attribute name="authority">iso639-2b</xsl:attribute>
                                        <xsl:value-of select="normalize-space(translate(//a1:component/@xml:lang,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz'))"/>
                                    </languageTerm>
                                </xsl:when>
                            </xsl:choose>
                        </language>
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:choose>
                            <xsl:when test="//a1:component/a1:header/a1:contentMeta/a1:titleGroup/a1:title[@type='main']/@xml:lang[string-length() &gt; 0]">
                                <language xmlns="http://www.loc.gov/mods/v3">
                                    <languageTerm xmlns="http://www.loc.gov/mods/v3">
                                        <xsl:attribute name="type">code</xsl:attribute>
                                        <xsl:attribute name="authority">rfc3066</xsl:attribute>
                                        <xsl:value-of select="//a1:component/a1:header/a1:contentMeta/a1:titleGroup/a1:title[@type='main']/@xml:lang"/>
                                    </languageTerm>
                                    <xsl:choose>
                                        <xsl:when test="//a1:component/a1:header/a1:contentMeta/a1:titleGroup/a1:title[@type='main']/@xml:lang">
                                            <languageTerm xmlns="http://www.loc.gov/mods/v3">
                                                <xsl:attribute name="type">code</xsl:attribute>
                                                <xsl:attribute name="authority">iso639-2b</xsl:attribute>
                                                <xsl:variable name="codeLang1">
                                                    <xsl:value-of select="//a1:component/a1:header/a1:contentMeta/a1:titleGroup/a1:title[@type='main']/@xml:lang"/>
                                                </xsl:variable>
                                                <xsl:variable name="codeLang">
                                                    <xsl:choose>
                                                        <xsl:when test="normalize-space($codeLang1)='aa'">aar</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ab'">abk</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='af'">afr</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ak'">aka</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='sq'">alb</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='am'">amh</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ar'">ara</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='an'">arg</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='hy'">hye</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='hy'">arm</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='as'">asm</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='av'">ava</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ae'">ave</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ay'">aym</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='az'">aze</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ba'">bak</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='bm'">bam</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='eu'">eus</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='eu'">baq</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='be'">bel</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='bn'">ben</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='bh'">bih</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='bi'">bis</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='bo'">bod</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='bs'">bos</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='br'">bre</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='bg'">bul</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='my'">bur</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='my'">mya</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ca'">cat</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='cs'">ces</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ch'">cha</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ce'">che</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='zh'">chi</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='cu'">chu</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='cv'">chv</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='kw'">cor</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='co'">cos</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='cr'">cre</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='cy'">cym</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='cs'">cze</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='da'">dan</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='de'">ger</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='dv'">div</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='nl'">dut</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='nl'">nld</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='dz'">dzo</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='en'">eng</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='eo'">epo</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='et'">est</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ee'">ewe</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='fo'">fao</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='fj'">fij</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='fi'">fin</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='fr'">fre</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='fy'">fry</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ff'">ful</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ka'">kat</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='de'">ger</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='gd'">gla</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ga'">gle</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='gl'">glg</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='gv'">glv</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='el'">gre</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='gn'">grn</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='gu'">guj</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ht'">hat</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ha'">hau</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='he'">heb</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='hz'">her</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='hi'">hin</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ho'">hmo</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='hr'">hrv</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='hu'">hun</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ig'">ibo</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='is'">isl</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='io'">ido</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ii'">iii</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='iu'">iku</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ie'">ile</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ia'">ina</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='id'">ind</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ik'">ipk</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='it'">ita</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='jv'">jav</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ja'">jpn</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='kl'">kal</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='kn'">kan</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ks'">kas</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='kr'">kau</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='kk'">kaz</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='km'">khm</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ki'">kik</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='rw'">kin</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ky'">kir</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='kv'">kom</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='kg'">kon</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ko'">kor</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='kj'">kua</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ku'">kur</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='lo'">lao</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='la'">lat</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='lv'">lav</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='li'">lim</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ln'">lin</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='lt'">lit</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='lb'">ltz</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='lu'">lub</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='lg'">lug</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='mk'">mac</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='mk'">mkd</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='mh'">mah</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ml'">mal</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='mi'">mri</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='mi'">mao</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='mr'">mar</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ms'">may</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ms'">msa</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='mg'">mlg</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='mt'">mlt</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='mn'">mon</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='na'">nau</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='nv'">nav</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='nr'">nbl</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='nd'">nde</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ng'">ndo</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ne'">nep</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='nn'">nno</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='nb'">nob</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='no'">nor</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ny'">nya</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='oc'">oci</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='oj'">oji</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='or'">ori</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='om'">orm</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='os'">oss</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='pa'">pan</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='fa'">fas</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='fa'">per</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='pi'">pli</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='pl'">pol</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='pt'">por</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ps'">pus</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='qu'">que</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='rm'">roh</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ro'">rum</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='rn'">run</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ru'">rus</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='sg'">sag</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='sa'">san</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='sr'">scc</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='si'">sin</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='sk'">slo</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='sk'">slk</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='sl'">slv</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='se'">sme</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='sm'">smo</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='sn'">sna</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='sd'">snd</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='so'">som</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='st'">sot</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='es'">spa</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='sq'">sqi</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='sc'">srd</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='sr'">srp</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ss'">ssw</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='su'">sun</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='sw'">swa</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='sv'">swe</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ty'">tah</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ta'">tam</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='tt'">tat</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='te'">tel</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='tg'">tgk</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='tl'">tgl</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='th'">tha</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='bo'">tib</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ti'">tir</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='to'">ton</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='tn'">tsn</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ts'">tso</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='tk'">tuk</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='tr'">tur</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='tw'">twi</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ug'">uig</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='uk'">ukr</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ur'">urd</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='uz'">uzb</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ve'">ven</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='vi'">vie</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='vo'">vol</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='cy'">wel</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='wa'">wln</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='wo'">wol</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='xh'">xho</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='yi'">yid</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='yo'">yor</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='za'">zha</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='zh'">zho</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='zu'">zul</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='AA'">aar</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='AB'">abk</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='AF'">afr</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='AK'">aka</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='SQ'">alb</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='AM'">amh</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='AR'">ara</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='AN'">arg</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='HY'">hye</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='HY'">arm</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='AS'">asm</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='AV'">ava</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='AE'">ave</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='AY'">aym</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='AZ'">aze</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='BA'">bak</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='BM'">bam</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='EU'">eus</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='EU'">baq</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='BE'">bel</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='BN'">ben</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='BH'">bih</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='BI'">bis</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='BO'">bod</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='BS'">bos</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='BR'">bre</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='BG'">bul</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='MY'">bur</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='MY'">mya</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='CA'">cat</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='CS'">ces</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='CH'">cha</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='CE'">che</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ZH'">chi</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='CU'">chu</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='CV'">chv</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='KW'">cor</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='CO'">cos</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='CR'">cre</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='CY'">cym</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='CS'">cze</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='DA'">dan</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='DE'">ger</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='DV'">div</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='NL'">dut</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='NL'">nld</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='DZ'">dzo</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='EN'">eng</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='EO'">epo</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ET'">est</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='EE'">ewe</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='FO'">fao</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='FJ'">fij</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='FI'">fin</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='FR'">fre</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='FY'">fry</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='FF'">ful</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='KA'">kat</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='GD'">gla</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='GA'">gle</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='GL'">glg</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='GV'">glv</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='EL'">gre</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='GN'">grn</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='GU'">guj</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='HT'">hat</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='HA'">hau</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='HE'">heb</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='HZ'">her</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='HI'">hin</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='HO'">hmo</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='HR'">hrv</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='HU'">hun</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='IG'">ibo</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='IS'">isl</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='IO'">ido</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='II'">iii</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='IU'">iku</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='IE'">ile</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='IA'">ina</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ID'">ind</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='IK'">ipk</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='IT'">ita</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='JV'">jav</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='JA'">jpn</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='KL'">kal</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='KN'">kan</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='KS'">kas</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='KR'">kau</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='KK'">kaz</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='KM'">khm</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='KI'">kik</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='RW'">kin</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='KY'">kir</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='KV'">kom</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='KG'">kon</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='KO'">kor</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='KJ'">kua</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='KU'">kur</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='LO'">lao</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='LA'">lat</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='LV'">lav</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='LI'">lim</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='LN'">lin</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='LT'">lit</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='LB'">ltz</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='LU'">lub</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='LG'">lug</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='MK'">mac</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='MK'">mkd</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='MH'">mah</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ML'">mal</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='MI'">mri</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='MI'">mao</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='MR'">mar</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='MS'">may</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='MS'">msa</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='MG'">mlg</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='MT'">mlt</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='MN'">mon</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='NA'">nau</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='NV'">nav</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='NR'">nbl</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ND'">nde</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='NG'">ndo</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='NE'">nep</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='NN'">nno</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='NB'">nob</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='NO'">nor</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='NY'">nya</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='OC'">oci</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='OJ'">oji</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='OR'">ori</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='OM'">orm</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='OS'">oss</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='PA'">pan</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='FA'">fas</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='FA'">per</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='PI'">pli</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='PL'">pol</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='PT'">por</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='PS'">pus</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='QU'">que</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='RM'">roh</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='RO'">rum</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='RN'">run</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='RU'">rus</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='SG'">sag</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='SA'">san</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='SR'">scc</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='SI'">sin</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='SK'">slo</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='SK'">slk</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='SL'">slv</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='SE'">sme</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='SM'">smo</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='SN'">sna</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='SD'">snd</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='SO'">som</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ST'">sot</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ES'">spa</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='SQ'">sqi</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='SC'">srd</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='SR'">srp</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='SS'">ssw</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='SU'">sun</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='SW'">swa</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='SV'">swe</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='TY'">tah</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='TA'">tam</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='TT'">tat</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='TE'">tel</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='TG'">tgk</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='TL'">tgl</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='TH'">tha</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='BO'">tib</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='TI'">tir</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='TO'">ton</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='TN'">tsn</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='TS'">tso</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='TK'">tuk</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='TR'">tur</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='TW'">twi</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='UG'">uig</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='UK'">ukr</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='UR'">urd</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='UZ'">uzb</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='VE'">ven</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='VI'">vie</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='VO'">vol</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='CY'">wel</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='WA'">wln</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='WO'">wol</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='XH'">xho</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='YI'">yid</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='YO'">yor</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ZA'">zha</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ZH'">zho</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ZU'">zul</xsl:when>
                                                    </xsl:choose>
                                                </xsl:variable>
                                                <xsl:value-of select="normalize-space($codeLang)"/>
                                            </languageTerm>
                                        </xsl:when>
                                    </xsl:choose>
                                </language>
                            </xsl:when>
                            <xsl:when test="//a1:component/@xml:lang[string-length() &gt; 0]">
                                <language xmlns="http://www.loc.gov/mods/v3">
                                    <languageTerm xmlns="http://www.loc.gov/mods/v3">
                                        <xsl:attribute name="type">code</xsl:attribute>
                                        <xsl:attribute name="authority">rfc3066</xsl:attribute>
                                            <xsl:value-of select="//a1:component/@xml:lang"/>
                                    </languageTerm>
                                    <xsl:choose>
                                        <xsl:when test="//a1:component/@xml:lang">
                                            <languageTerm xmlns="http://www.loc.gov/mods/v3">
                                                <xsl:attribute name="type">code</xsl:attribute>
                                                <xsl:attribute name="authority">iso639-2b</xsl:attribute>
                                                <xsl:variable name="codeLang1">
                                                    <xsl:value-of select="//a1:component/@xml:lang"/>
                                                </xsl:variable>
                                                <xsl:variable name="codeLang">
                                                    <xsl:choose>
                                                        <xsl:when test="normalize-space($codeLang1)='aa'">aar</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ab'">abk</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='af'">afr</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ak'">aka</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='sq'">alb</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='am'">amh</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ar'">ara</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='an'">arg</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='hy'">hye</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='hy'">arm</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='as'">asm</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='av'">ava</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ae'">ave</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ay'">aym</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='az'">aze</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ba'">bak</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='bm'">bam</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='eu'">eus</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='eu'">baq</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='be'">bel</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='bn'">ben</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='bh'">bih</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='bi'">bis</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='bo'">bod</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='bs'">bos</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='br'">bre</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='bg'">bul</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='my'">bur</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='my'">mya</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ca'">cat</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='cs'">ces</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ch'">cha</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ce'">che</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='zh'">chi</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='cu'">chu</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='cv'">chv</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='kw'">cor</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='co'">cos</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='cr'">cre</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='cy'">cym</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='cs'">cze</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='da'">dan</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='de'">ger</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='dv'">div</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='nl'">dut</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='nl'">nld</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='dz'">dzo</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='en'">eng</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='eo'">epo</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='et'">est</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ee'">ewe</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='fo'">fao</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='fj'">fij</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='fi'">fin</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='fr'">fre</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='fy'">fry</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ff'">ful</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ka'">kat</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='gd'">gla</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ga'">gle</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='gl'">glg</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='gv'">glv</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='el'">gre</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='gn'">grn</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='gu'">guj</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ht'">hat</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ha'">hau</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='he'">heb</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='hz'">her</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='hi'">hin</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ho'">hmo</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='hr'">hrv</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='hu'">hun</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ig'">ibo</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='is'">isl</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='io'">ido</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ii'">iii</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='iu'">iku</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ie'">ile</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ia'">ina</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='id'">ind</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ik'">ipk</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='it'">ita</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='jv'">jav</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ja'">jpn</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='kl'">kal</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='kn'">kan</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ks'">kas</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='kr'">kau</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='kk'">kaz</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='km'">khm</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ki'">kik</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='rw'">kin</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ky'">kir</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='kv'">kom</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='kg'">kon</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ko'">kor</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='kj'">kua</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ku'">kur</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='lo'">lao</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='la'">lat</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='lv'">lav</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='li'">lim</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ln'">lin</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='lt'">lit</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='lb'">ltz</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='lu'">lub</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='lg'">lug</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='mk'">mac</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='mk'">mkd</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='mh'">mah</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ml'">mal</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='mi'">mri</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='mi'">mao</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='mr'">mar</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ms'">may</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ms'">msa</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='mg'">mlg</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='mt'">mlt</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='mn'">mon</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='na'">nau</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='nv'">nav</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='nr'">nbl</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='nd'">nde</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ng'">ndo</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ne'">nep</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='nn'">nno</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='nb'">nob</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='no'">nor</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ny'">nya</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='oc'">oci</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='oj'">oji</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='or'">ori</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='om'">orm</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='os'">oss</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='pa'">pan</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='fa'">fas</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='fa'">per</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='pi'">pli</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='pl'">pol</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='pt'">por</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ps'">pus</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='qu'">que</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='rm'">roh</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ro'">rum</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='rn'">run</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ru'">rus</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='sg'">sag</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='sa'">san</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='sr'">scc</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='si'">sin</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='sk'">slo</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='sk'">slk</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='sl'">slv</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='se'">sme</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='sm'">smo</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='sn'">sna</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='sd'">snd</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='so'">som</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='st'">sot</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='es'">spa</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='sq'">sqi</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='sc'">srd</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='sr'">srp</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ss'">ssw</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='su'">sun</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='sw'">swa</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='sv'">swe</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ty'">tah</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ta'">tam</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='tt'">tat</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='te'">tel</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='tg'">tgk</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='tl'">tgl</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='th'">tha</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='bo'">tib</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ti'">tir</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='to'">ton</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='tn'">tsn</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ts'">tso</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='tk'">tuk</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='tr'">tur</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='tw'">twi</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ug'">uig</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='uk'">ukr</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ur'">urd</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='uz'">uzb</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ve'">ven</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='vi'">vie</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='vo'">vol</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='cy'">wel</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='wa'">wln</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='wo'">wol</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='xh'">xho</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='yi'">yid</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='yo'">yor</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='za'">zha</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='zh'">zho</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='zu'">zul</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='AA'">aar</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='AB'">abk</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='AF'">afr</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='AK'">aka</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='SQ'">alb</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='AM'">amh</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='AR'">ara</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='AN'">arg</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='HY'">hye</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='HY'">arm</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='AS'">asm</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='AV'">ava</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='AE'">ave</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='AY'">aym</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='AZ'">aze</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='BA'">bak</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='BM'">bam</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='EU'">eus</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='EU'">baq</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='BE'">bel</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='BN'">ben</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='BH'">bih</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='BI'">bis</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='BO'">bod</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='BS'">bos</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='BR'">bre</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='BG'">bul</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='MY'">bur</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='MY'">mya</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='CA'">cat</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='CS'">ces</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='CH'">cha</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='CE'">che</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ZH'">chi</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='CU'">chu</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='CV'">chv</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='KW'">cor</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='CO'">cos</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='CR'">cre</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='CY'">cym</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='CS'">cze</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='DA'">dan</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='DE'">ger</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='DV'">div</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='NL'">dut</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='NL'">nld</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='DZ'">dzo</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='EN'">eng</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='EO'">epo</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ET'">est</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='EE'">ewe</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='FO'">fao</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='FJ'">fij</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='FI'">fin</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='FR'">fre</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='FY'">fry</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='FF'">ful</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='KA'">kat</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='DE'">ger</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='GD'">gla</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='GA'">gle</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='GL'">glg</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='GV'">glv</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='EL'">gre</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='GN'">grn</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='GU'">guj</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='HT'">hat</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='HA'">hau</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='HE'">heb</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='HZ'">her</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='HI'">hin</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='HO'">hmo</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='HR'">hrv</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='HU'">hun</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='IG'">ibo</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='IS'">isl</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='IO'">ido</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='II'">iii</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='IU'">iku</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='IE'">ile</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='IA'">ina</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ID'">ind</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='IK'">ipk</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='IT'">ita</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='JV'">jav</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='JA'">jpn</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='KL'">kal</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='KN'">kan</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='KS'">kas</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='KR'">kau</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='KK'">kaz</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='KM'">khm</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='KI'">kik</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='RW'">kin</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='KY'">kir</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='KV'">kom</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='KG'">kon</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='KO'">kor</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='KJ'">kua</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='KU'">kur</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='LO'">lao</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='LA'">lat</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='LV'">lav</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='LI'">lim</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='LN'">lin</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='LT'">lit</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='LB'">ltz</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='LU'">lub</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='LG'">lug</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='MK'">mac</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='MK'">mkd</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='MH'">mah</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ML'">mal</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='MI'">mri</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='MI'">mao</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='MR'">mar</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='MS'">may</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='MS'">msa</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='MG'">mlg</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='MT'">mlt</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='MN'">mon</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='NA'">nau</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='NV'">nav</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='NR'">nbl</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ND'">nde</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='NG'">ndo</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='NE'">nep</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='NN'">nno</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='NB'">nob</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='NO'">nor</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='NY'">nya</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='OC'">oci</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='OJ'">oji</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='OR'">ori</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='OM'">orm</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='OS'">oss</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='PA'">pan</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='FA'">fas</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='FA'">per</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='PI'">pli</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='PL'">pol</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='PT'">por</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='PS'">pus</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='QU'">que</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='RM'">roh</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='RO'">rum</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='RN'">run</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='RU'">rus</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='SG'">sag</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='SA'">san</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='SR'">scc</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='SI'">sin</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='SK'">slo</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='SK'">slk</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='SL'">slv</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='SE'">sme</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='SM'">smo</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='SN'">sna</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='SD'">snd</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='SO'">som</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ST'">sot</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ES'">spa</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='SQ'">sqi</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='SC'">srd</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='SR'">srp</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='SS'">ssw</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='SU'">sun</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='SW'">swa</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='SV'">swe</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='TY'">tah</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='TA'">tam</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='TT'">tat</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='TE'">tel</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='TG'">tgk</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='TL'">tgl</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='TH'">tha</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='BO'">tib</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='TI'">tir</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='TO'">ton</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='TN'">tsn</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='TS'">tso</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='TK'">tuk</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='TR'">tur</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='TW'">twi</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='UG'">uig</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='UK'">ukr</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='UR'">urd</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='UZ'">uzb</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='VE'">ven</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='VI'">vie</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='VO'">vol</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='CY'">wel</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='WA'">wln</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='WO'">wol</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='XH'">xho</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='YI'">yid</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='YO'">yor</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ZA'">zha</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ZH'">zho</xsl:when>
                                                        <xsl:when test="normalize-space($codeLang1)='ZU'">zul</xsl:when>
                                                    </xsl:choose>
                                                </xsl:variable>
                                                <xsl:value-of select="normalize-space($codeLang)"/>
                                            </languageTerm>
                                        </xsl:when>
                                    </xsl:choose>
                                </language>
                            </xsl:when>
                        </xsl:choose>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:if>
            
            <!-- ******************* PhysicalDescription ******************************-->
            <physicalDescription xmlns="http://www.loc.gov/mods/v3">
                <internetMediaType xmlns="http://www.loc.gov/mods/v3">
                    <xsl:text>text/html</xsl:text>
                </internetMediaType>
                <xsl:if test="//a1:contentMeta/a1:countGroup/a1:count[@type='figureTotal']/@number [string-length() &gt; 0] !='NA'">
                    <xsl:if test="//a1:contentMeta/a1:countGroup/a1:count[@type='figureTotal']/@number [string-length() &gt; 0] !=0">
                        <extent xmlns="http://www.loc.gov/mods/v3">
                            <xsl:attribute name="unit">figures</xsl:attribute>
                            <xsl:value-of select="normalize-space(//a1:component/a1:header/a1:contentMeta/a1:countGroup/a1:count[@type='figureTotal']/@number)"/>
                        </extent>
                    </xsl:if>
                </xsl:if>
                <xsl:if test="//a1:contentMeta/a1:countGroup/a1:count[@type='tableTotal']/@number [string-length() &gt; 0] !='NA'">
                    <xsl:if test="//a1:contentMeta/a1:countGroup/a1:count[@type='tableTotal']/@number [string-length() &gt; 0] !=0">
                        <extent xmlns="http://www.loc.gov/mods/v3">
                            <xsl:attribute name="unit">tables</xsl:attribute>
                            <xsl:value-of select="normalize-space(//a1:contentMeta/a1:countGroup/a1:count[@type='tableTotal']/@number)"/>
                        </extent>
                    </xsl:if>
                </xsl:if>
                <xsl:if test="//a1:contentMeta/a1:countGroup/a1:count[@type='formulaTotal']/@number [string-length() &gt; 0] !='NA'">
                    <xsl:if test="//a1:contentMeta/a1:countGroup/a1:count[@type='formulaTotal']/@number [string-length() &gt; 0] !=0">
                        <extent xmlns="http://www.loc.gov/mods/v3">
                            <xsl:attribute name="unit">formulas</xsl:attribute>
                            <xsl:value-of select="normalize-space(//a1:contentMeta/a1:countGroup/a1:count[@type='formulaTotal']/@number)"/>
                        </extent>
                    </xsl:if>
                </xsl:if>
                <xsl:if test="//a1:contentMeta/a1:countGroup/a1:count[@type='referenceTotal']/@number[string-length() &gt; 0]  !='NA'">
                    <xsl:if test="//a1:contentMeta/a1:countGroup/a1:count[@type='referenceTotal']/@number[string-length() &gt; 0]  !=0">
                        <extent xmlns="http://www.loc.gov/mods/v3">
                            <xsl:attribute name="unit">references</xsl:attribute>
                            <xsl:value-of select="normalize-space(//a1:contentMeta/a1:countGroup/a1:count[@type='referenceTotal']/@number)"/>
                        </extent>
                    </xsl:if>
                </xsl:if>
                <xsl:if test="//a1:contentMeta/a1:countGroup/a1:count[@type='wordTotal']/@number[string-length() &gt; 0]  !='NA'">
                    <xsl:if test="//a1:contentMeta/a1:countGroup/a1:count[@type='wordTotal']/@number[string-length() &gt; 0]  !=0">
                        <extent xmlns="http://www.loc.gov/mods/v3">
                            <xsl:attribute name="unit">words</xsl:attribute>
                            <xsl:value-of select="normalize-space(//a1:contentMeta/a1:countGroup/a1:count[@type='wordTotal']/@number)"/>
                        </extent>
                    </xsl:if>
                </xsl:if>
            </physicalDescription>

            <!-- ******************* Abstract ******************************-->
            <xsl:if test="normalize-space(//a1:abstract)">
                <xsl:for-each select="//a1:abstract">
                    <abstract xmlns="http://www.loc.gov/mods/v3">
                    <xsl:choose>
                        <xsl:when test="contains(@type,'graphical')">
                            <xsl:attribute name="type">
                                <xsl:text>graphical</xsl:text>
                            </xsl:attribute>
                        </xsl:when>
                        <xsl:when test="contains(@type,'synopsis')">
                            <xsl:attribute name="type">
                                <xsl:text>synopsis</xsl:text>
                            </xsl:attribute>
                        </xsl:when>
                        <xsl:when test="contains(@type,'short')">
                            <xsl:attribute name="type">
                                <xsl:text>short</xsl:text>
                            </xsl:attribute>
                        </xsl:when>
                    </xsl:choose>
                        <xsl:choose>
                            <xsl:when test="@xml:lang[string-length() &gt; 0] | @lang[string-length() &gt; 0]">
                                <xsl:attribute name="lang">
                                    <xsl:value-of select="translate(@xml:lang | @lang,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')"/>
                                </xsl:attribute>
                            </xsl:when>
                        </xsl:choose>
                        <xsl:variable name="abs">
                            <xsl:apply-templates select="."/>
                        </xsl:variable>
                        <xsl:choose>
                            <xsl:when test="a1:section/a1:title">
                                <xsl:variable name="section">
                                    <xsl:apply-templates select="a1:section"/>
                                </xsl:variable>
                                <xsl:value-of select="normalize-space($section)"/>
                            </xsl:when>
                            <xsl:otherwise>
                                <xsl:value-of select="normalize-space($abs)"/>
                            </xsl:otherwise>
                        </xsl:choose>
                    </abstract>
                </xsl:for-each>
            </xsl:if>
            <xsl:if test="//a1:component/a1:header/a1:contentMeta/a1:supportingInformation/a1:supportingInfoItem[string-length() &gt; 0] and not(//a1:component/a1:header/a1:contentMeta/a1:supportingInformation/a1:p)">
                <note xmlns="http://www.loc.gov/mods/v3">
                    <xsl:attribute name="type">additional physical form</xsl:attribute>
                    <xsl:for-each select="//a1:component/a1:header/a1:contentMeta/a1:supportingInformation/a1:supportingInfoItem">
                        <xsl:variable name="apf">
                            <xsl:apply-templates select="."/>
                        </xsl:variable>
                        <xsl:value-of select="normalize-space($apf)"/>
                    </xsl:for-each>
                </note>
            </xsl:if>
            <!-- noteRef -->
            <xsl:if test="//a1:component/a1:header/a1:contentMeta/a1:titleGroup/a1:title/a1:link/@href[string-length() &gt; 0]">
                <xsl:for-each select="//a1:component/a1:header/a1:contentMeta/a1:titleGroup/a1:title/a1:link/@href">
                    <note>
                        <xsl:variable name="not">
                            <xsl:value-of select="translate(. ,'#','')"/>
                        </xsl:variable>
                        <xsl:attribute name="type">content</xsl:attribute>
                        <xsl:variable name="note">
                            <xsl:apply-templates select="//a1:noteGroup/a1:note[@xml:id=$not]"/>
                        </xsl:variable>
                        <xsl:text>*</xsl:text>
                        <xsl:value-of select="normalize-space($note)"/>
                    </note>
                </xsl:for-each>
            </xsl:if>
            <!-- fundingInformation <note type="funding"></note>-->
            <xsl:if test="//a1:component/a1:header/a1:contentMeta/a1:fundingInfo[string-length() &gt; 0]">
                <xsl:for-each select="//a1:component/a1:header/a1:contentMeta/a1:fundingInfo">
                <note xmlns="http://www.loc.gov/mods/v3">
                    <xsl:attribute name="type">funding</xsl:attribute>
                    <xsl:variable name="funding">
                        <xsl:apply-templates select="a1:fundingAgency"/>
                    </xsl:variable>
                    <xsl:value-of select="normalize-space($funding)"/>
                    <xsl:if test="a1:fundingNumber">
                        <xsl:text> - </xsl:text>
                        <xsl:for-each select="a1:fundingNumber">
                        <xsl:choose>
                            <xsl:when test="contains(.,'No.')">
                                <xsl:value-of select="normalize-space(.)"/>
                            </xsl:when>
                            <xsl:otherwise>
                                <xsl:text>No. </xsl:text>
                                <xsl:value-of select="normalize-space(.)"/>
                            </xsl:otherwise>
                        </xsl:choose>
                            <xsl:text>; </xsl:text>
                        </xsl:for-each>
                    </xsl:if>
                </note>
                </xsl:for-each>
            </xsl:if>
            <!-- ******************* Subject ******************************-->
            <xsl:if test="//a1:component/a1:header/a1:contentMeta/a1:keywordGroup[string-length() &gt; 0]">
                <xsl:for-each select="//a1:component/a1:header/a1:contentMeta/a1:keywordGroup">
                    <subject xmlns="http://www.loc.gov/mods/v3">
                            <xsl:choose>
                                <xsl:when test="@xml:lang[string-length() &gt; 0] | @lang[string-length() &gt; 0]">
                                    <xsl:attribute name="lang">
                                        <xsl:value-of select="translate(@xml:lang | @lang,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')"/>
                                    </xsl:attribute>
                                </xsl:when>
                            </xsl:choose>
                        <genre xmlns="http://www.loc.gov/mods/v3">
                            <xsl:text>Keywords</xsl:text>
                        </genre>
                        <xsl:for-each select="a1:keyword">
                            <topic xmlns="http://www.loc.gov/mods/v3">
                                <xsl:variable name="kwd">
                                    <xsl:apply-templates select="."/>
                                </xsl:variable>
                                <xsl:value-of select="normalize-space($kwd)"/>
                            </topic>
                        </xsl:for-each>
                    </subject>
                </xsl:for-each>
            </xsl:if>

            <relatedItem xmlns="http://www.loc.gov/mods/v3">
                <xsl:attribute name="type">host</xsl:attribute>
                <xsl:if test="//a1:component/a1:header/a1:publicationMeta/a1:titleGroup/a1:title[@type='main'][string-length() &gt; 0]">
                    <titleInfo xmlns="http://www.loc.gov/mods/v3">
                        
                        <title xmlns="http://www.loc.gov/mods/v3">
                            <xsl:variable name="ttl">
                                <xsl:apply-templates select="//a1:component/a1:header/a1:publicationMeta/a1:titleGroup/a1:title[@type='main']"/>
                            </xsl:variable>
                            <xsl:value-of select="normalize-space($ttl)"/>
                        </title>
                        <xsl:if test="//a1:component/a1:header/a1:publicationMeta/a1:titleGroup/a1:title[@type='subtitle'][string-length() &gt; 0]">
                            <subTitle xmlns="http://www.loc.gov/mods/v3">
                                <xsl:variable name="sttl">
                                    <xsl:apply-templates select="//a1:component/a1:header/a1:publicationMeta/a1:titleGroup/a1:title[@type='subtitle']"/>
                                </xsl:variable>
                                <xsl:value-of select="normalize-space($sttl)"/>
                            </subTitle>
                        </xsl:if>
                    </titleInfo>
                </xsl:if>
                <xsl:if test="//a1:component/a1:header/a1:publicationMeta/a1:titleGroup/a1:title[@type='short'][string-length() &gt; 0]">
                    <titleInfo>
                        <xsl:attribute name="type">
                            <xsl:text>abbreviated</xsl:text>
                        </xsl:attribute>
                        <title>
                            <xsl:variable name="abttl">
                                <xsl:apply-templates select="//a1:component/a1:header/a1:publicationMeta/a1:titleGroup/a1:title[@type='short']"/>
                            </xsl:variable>
                            <xsl:value-of select="normalize-space($abttl)"/>
                        </title>
                    </titleInfo>
                </xsl:if>
                <!--editors-->
                <xsl:if test="//a1:component/a1:header/a1:publicationMeta/a1:creators">
                    <xsl:for-each select="//a1:component/a1:header/a1:publicationMeta/a1:creators/a1:creator">
                    <name xmlns="http://www.loc.gov/mods/v3">
                        <xsl:attribute name="type">personal</xsl:attribute>
                        <xsl:call-template name="name2"/>
                        <!-- Affiliation -->
                        <xsl:if test="@affiliationRef">
                            <xsl:call-template name="affiliation"/>
                        </xsl:if>
                        <!-- Affiliation corresp-->
                        <xsl:if test="@corresponding='yes'">
                            <xsl:for-each select="//a1:publicationMeta/a1:correspondenceTo/a1:lineatedText/a1:line">
                                <affiliation xmlns="http://www.loc.gov/mods/v3">
                                    <xsl:text>Correspondence: </xsl:text>
                                    <xsl:variable name="corresp">
                                        <xsl:apply-templates select="."/>
                                    </xsl:variable>
                                    <xsl:value-of select="normalize-space($corresp)"/>
                                </affiliation>
                            </xsl:for-each>
                        </xsl:if>
                        <xsl:if test="@affiliationRef=@correspondenceRef and //a1:publicationMeta/a1:correspondenceTo/a1:lineatedText/a1:line[string-length()&gt;0]">
                            <affiliation xmlns="http://www.loc.gov/mods/v3">
                                <xsl:text>Correspondence: </xsl:text>
                                <xsl:variable name="corresp">
                                    <xsl:apply-templates select="//a1:publicationMeta/a1:correspondenceTo/a1:lineatedText/a1:line"/>
                                </xsl:variable>
                                <xsl:value-of select="normalize-space($corresp)"/>
                            </affiliation>
                        </xsl:if>
                        <!-- EMAIL -->
                        <xsl:if test="a1:contactDetails/a1:email[string-length()&gt;0]">
                            <xsl:for-each select="a1:contactDetails/a1:email">
                                <affiliation xmlns="http://www.loc.gov/mods/v3">
                                    <xsl:text>E-mail: </xsl:text>
                                    <xsl:variable name="email">
                                        <xsl:apply-templates select="."/>
                                    </xsl:variable>
                                    <xsl:value-of select="normalize-space($email)"/>
                                </affiliation>
                            </xsl:for-each>
                        </xsl:if>
                        <!-- traitement des roles -->
                        <xsl:if test="@creatorRole='editor'">
                            <role xmlns="http://www.loc.gov/mods/v3">
                                <roleTerm xmlns="http://www.loc.gov/mods/v3">
                                    <xsl:attribute name="type">text</xsl:attribute>
                                    <xsl:text>editor</xsl:text>
                                </roleTerm>
                            </role>
                        </xsl:if>
                        <xsl:if test="@creatorRole='guestEditor'">
                            <role xmlns="http://www.loc.gov/mods/v3">
                                <roleTerm xmlns="http://www.loc.gov/mods/v3">
                                    <xsl:attribute name="type">text</xsl:attribute>
                                    <xsl:text>editor</xsl:text>
                                </roleTerm>
                            </role>
                        </xsl:if>
                        <xsl:if test="a1:jobTitle">
                            <description xmlns="http://www.loc.gov/mods/v3">
                                <xsl:variable name="jobTitle">
                                    <xsl:apply-templates select="a1:jobTitle"/>
                                </xsl:variable>
                                <xsl:value-of select="normalize-space($jobTitle)"/>
                            </description>
                        </xsl:if>
                    </name>
                        </xsl:for-each>
                </xsl:if>
                <!-- corpauthor -->
                <xsl:if test="//a1:iss-editor/a1:grp_edt[string-length() &gt; 0]">
                    <xsl:for-each select="//iss-editor/grp_edt">
                        <name xmlns="http://www.loc.gov/mods/v3">
                            <xsl:attribute name="type">corporate</xsl:attribute>
                            <namePart xmlns="http://www.loc.gov/mods/v3">
                                <xsl:variable name="grp_edt">
                                    <xsl:apply-templates select="//a1:iss-editor/a1:grp_edt"/>
                                </xsl:variable>
                                <xsl:value-of select="normalize-space($grp_edt)"/>
                            </namePart>
                        </name>
                    </xsl:for-each>
                </xsl:if>
                <!-- Note     -->
                <xsl:if test="//a1:component/a1:header/a1:contentMeta/a1:supportingInformation/a1:p[string-length() &gt; 0]">
                    <note xmlns="http://www.loc.gov/mods/v3">
                        <xsl:attribute name="type">
                            <xsl:text>content</xsl:text>
                        </xsl:attribute>
                        <xsl:for-each select="//a1:component/a1:header/a1:contentMeta/a1:supportingInformation/a1:p">
                            <xsl:text> </xsl:text>
                            <xsl:variable name="supportingInformation">
                                <xsl:apply-templates select="//a1:component/a1:header/a1:contentMeta/a1:supportingInformation/a1:p"/>
                            </xsl:variable>
                            <xsl:value-of select="normalize-space($supportingInformation)"/>
                        </xsl:for-each>
                        <xsl:if test="//a1:component/a1:header/a1:contentMeta/a1:supportingInformation/a1:supportingInfoItem[string-length() &gt; 0]">
                            <xsl:text>Supporting Info Item: </xsl:text>
                            <xsl:for-each select="//a1:component/a1:header/a1:contentMeta/a1:supportingInformation/a1:supportingInfoItem">
                                <xsl:variable name="caption">
                                    <xsl:apply-templates select="a1:caption"/>
                                </xsl:variable>
                                <xsl:value-of select="normalize-space($caption)"/>
                                <xsl:text> - </xsl:text>
                            </xsl:for-each>
                        </xsl:if>
                    </note>
                </xsl:if>
                <!-- ******************* Subject ******************************-->
                <xsl:choose>
                    <xsl:when test="//a1:subjectInfo[string-length() &gt; 0 ]">
                        <subject xmlns="http://www.loc.gov/mods/v3">
                            <xsl:if test="//a1:subjectInfo/a1:subject/@href">
                                <genre xmlns="http://www.loc.gov/mods/v3">
                                    <xsl:text>Index Terms</xsl:text>
                                </genre>
                            </xsl:if>
                            <xsl:for-each select="//a1:subjectInfo/a1:subject">
                                <topic xmlns="http://www.loc.gov/mods/v3">
                                    <xsl:if test="@href">
                                       <!-- <xsl:if test="contains(@href,'http://psi.agu.org/')">
                                        <xsl:attribute name="authority"></xsl:attribute>
                                        </xsl:if>-->
                                        <xsl:attribute name="authorityURI">
                                            <xsl:value-of select="@href"/>
                                        </xsl:attribute>
                                    </xsl:if>
                                    <xsl:variable name="kw">
                                        <xsl:apply-templates select="."/>
                                    </xsl:variable>
                                    <xsl:value-of select="normalize-space($kw)"/>
                                </topic>
                            </xsl:for-each>
                        </subject>
                    </xsl:when>
                    </xsl:choose>
                <xsl:choose>
                    <xsl:when test="//a1:publicationMeta[@level='unit']/a1:titleGroup/a1:title[@type='articleCategory'][string-length() &gt; 0 ]">
                        <subject xmlns="http://www.loc.gov/mods/v3">
                            <xsl:for-each select="//a1:publicationMeta[@level='unit']/a1:titleGroup/a1:title">
                                <xsl:if test="@type='articleCategory'">
                                    <genre xmlns="http://www.loc.gov/mods/v3">
                                        <xsl:text>article category</xsl:text>
                                    </genre>
                                </xsl:if>
                            </xsl:for-each>
                            <xsl:for-each select="//a1:publicationMeta[@level='unit']/a1:titleGroup/a1:title[@type='articleCategory']">
                                <topic xmlns="http://www.loc.gov/mods/v3">
                                    <xsl:variable name="kw">
                                        <xsl:apply-templates select="."/>
                                    </xsl:variable>
                                    <xsl:value-of select="normalize-space($kw)"/>
                                </topic>
                            </xsl:for-each>
                        </subject>
                    </xsl:when>
                </xsl:choose>
                <xsl:if test="//a1:component/a1:header/a1:publicationMeta/a1:issn[@type='print'][string-length() &gt; 0]">
                    <identifier xmlns="http://www.loc.gov/mods/v3">
                        <xsl:attribute name="type">ISSN</xsl:attribute>
                        <xsl:value-of select="normalize-space(//a1:component/a1:header/a1:publicationMeta/a1:issn[@type='print'])"/>
                    </identifier>
                </xsl:if>
                <xsl:if test="//a1:component/a1:header/a1:publicationMeta/a1:issn[@type='electronic'][string-length() &gt; 0]">
                    <identifier xmlns="http://www.loc.gov/mods/v3">
                        <xsl:attribute name="type">eISSN</xsl:attribute>
                        <xsl:value-of select="normalize-space(//a1:component/a1:header/a1:publicationMeta/a1:issn[@type='electronic'])"/>
                    </identifier>
                </xsl:if>
                <!-- DOI niveau Journal objet unique et non niveau série -->
                <xsl:if test="//a1:component/a1:header/a1:publicationMeta[@level='product']/a1:doi[string-length() &gt; 0]">
                    <identifier xmlns="http://www.loc.gov/mods/v3">
                        <xsl:attribute name="type">DOI</xsl:attribute>
                        <xsl:value-of select="normalize-space(//a1:component/a1:header/a1:publicationMeta[@level='product']/a1:doi)"/>
                    </identifier>
                </xsl:if>
                <xsl:if test="//a1:component/a1:header/a1:publicationMeta[@level='product']/a1:idGroup/a1:id[@type='coden']/@value[string-length() &gt; 0]">
                    <identifier xmlns="http://www.loc.gov/mods/v3">
                        <xsl:attribute name="type">CODEN</xsl:attribute>
                        <xsl:value-of select="normalize-space(//a1:component/a1:header/a1:publicationMeta[@level='product']/a1:idGroup/a1:id[@type='coden']/@value)"/>
                    </identifier>
                </xsl:if>
                <xsl:if test="//a1:component/a1:header/a1:publicationMeta/a1:idGroup/a1:id/@value[string-length() &gt; 0]">
                    <identifier xmlns="http://www.loc.gov/mods/v3">
                        <xsl:attribute name="type">PublisherID</xsl:attribute>
                        <xsl:value-of select="normalize-space(//a1:component/a1:header/a1:publicationMeta/a1:idGroup/a1:id/@value)"/>
                    </identifier>
                </xsl:if>
                <!-- Part -->
                <xsl:if test="//a1:component/a1:header/a1:publicationMeta/a1:numberingGroup/a1:numbering[@type='journalVolume'][string-length() &gt; 0] | //a1:component/a1:header/a1:publicationMeta/a1:numberingGroup/a1:numbering[@type='journalIssue'][string-length() &gt; 0]">
                    <part xmlns="http://www.loc.gov/mods/v3">
                        <xsl:if test="//a1:component/a1:header/a1:publicationMeta/a1:coverDate/@startDate[string-length() &gt; 0]">
                            <date xmlns="http://www.loc.gov/mods/v3">
                                <xsl:choose>
                                    <xsl:when
                                        test="contains(//a1:component/a1:header/a1:publicationMeta/a1:coverDate/@startDate,'-')">
                                        <xsl:value-of select="substring-before((//a1:component/a1:header/a1:publicationMeta/a1:coverDate/@startDate),'-')"/>
                                    </xsl:when>
                                    <xsl:otherwise>
                                        <xsl:value-of select="normalize-space(//a1:component/a1:header/a1:publicationMeta/a1:coverDate/@startDate)"/>
                                    </xsl:otherwise>
                                </xsl:choose>
                            </date>
                        </xsl:if>
                        <!-- ************************* Special Issue pour niveau analytique + niveau ud2 mono *****************-->
                        <xsl:if test="//a1:publicationMeta[@level='part']/a1:titleGroup/a1:title[@type='specialIssueTitle'][string-length() &gt; 0]">
                                <detail xmlns="http://www.loc.gov/mods/v3">
                                    <xsl:attribute name="type">
                                        <xsl:text>title</xsl:text>
                                    </xsl:attribute>
                                    <title xmlns="http://www.loc.gov/mods/v3">
                                        <xsl:variable name="dttl">
                                            <xsl:apply-templates select="//a1:publicationMeta[@level='part']/a1:titleGroup/a1:title[@type='specialIssueTitle']"/>
                                        </xsl:variable>
                                        <xsl:value-of select="normalize-space($dttl)"/>
                                        <xsl:if test="//a1:publicationMeta[@level='part']/a1:titleGroup/a1:title[@type='specialIssueSubtitle'][string-length() &gt; 0]">
                                            <xsl:text> : </xsl:text>
                                            <xsl:variable name="ttl">
                                                <xsl:apply-templates select="//a1:publicationMeta[@level='part']/a1:titleGroup/a1:title[@type='specialIssueSubtitle']"/>
                                            </xsl:variable>
                                            <xsl:value-of select="normalize-space($ttl)"/>
                                        </xsl:if>
                                    </title>
                                </detail>
                        </xsl:if>
                        <xsl:if test="//a1:component/a1:header/a1:publicationMeta/a1:numberingGroup/a1:numbering[@type='journalVolume'][string-length() &gt; 0]">
                            <detail xmlns="http://www.loc.gov/mods/v3">
                                <xsl:attribute name="type">volume</xsl:attribute>
                                <caption xmlns="http://www.loc.gov/mods/v3">
                                    <xsl:text>vol.</xsl:text>
                                </caption>
                                <number xmlns="http://www.loc.gov/mods/v3">
                                    <xsl:value-of select="normalize-space(//a1:component/a1:header/a1:publicationMeta/a1:numberingGroup/a1:numbering[@type='journalVolume'])"/>
                                </number>
                            </detail>
                        </xsl:if>
                        <xsl:if test="//a1:component/a1:header/a1:publicationMeta/a1:numberingGroup/a1:numbering[@type='journalIssue'][string-length() &gt; 0]">
                            <detail xmlns="http://www.loc.gov/mods/v3">
                                <xsl:attribute name="type">issue</xsl:attribute>
                                <caption xmlns="http://www.loc.gov/mods/v3">
                                    <xsl:text>no.</xsl:text>
                                </caption>
                                <number xmlns="http://www.loc.gov/mods/v3">
                                    <xsl:value-of select="normalize-space(//a1:component/a1:header/a1:publicationMeta/a1:numberingGroup/a1:numbering[@type='journalIssue'])"/>
                                </number>
                            </detail>
                        </xsl:if>
                        <!-- supplement -->
                        <xsl:if test="//a1:component/a1:header/a1:publicationMeta/a1:numberingGroup/a1:numbering[@type='supplement'][string-length() &gt; 0]">
                            <detail xmlns="http://www.loc.gov/mods/v3">
                                <xsl:attribute name="type">supplement</xsl:attribute>
                                <caption xmlns="http://www.loc.gov/mods/v3">
                                    <xsl:text>Suppl. no.</xsl:text>
                                </caption>
                                <number xmlns="http://www.loc.gov/mods/v3">
                                    <xsl:value-of select="normalize-space(//a1:component/a1:header/a1:publicationMeta/a1:numberingGroup/a1:numbering[@type='supplement'])"/>
                                </number>
                            </detail>
                        </xsl:if>
                        <!-- ******************* pagination ******************************-->
                            <extent xmlns="http://www.loc.gov/mods/v3">
                                <xsl:attribute name="unit">pages</xsl:attribute>
                                <xsl:if test="//a1:component/a1:header/a1:publicationMeta/a1:numberingGroup/a1:numbering[@type='pageFirst'][string-length() &gt; 0] !=0">
                                    <xsl:if test="//a1:component/a1:header/a1:publicationMeta/a1:numberingGroup/a1:numbering[@type='pageFirst'][string-length() &gt; 0] !='no'">
                                        <start xmlns="http://www.loc.gov/mods/v3">
                                            <xsl:value-of select="normalize-space(//a1:component/a1:header/a1:publicationMeta/a1:numberingGroup/a1:numbering[@type='pageFirst'])"/>
                                        </start>
                                    </xsl:if>
                                </xsl:if>
                                <xsl:if test="//a1:component/a1:header/a1:publicationMeta/a1:numberingGroup/a1:numbering[@type='pageLast'][string-length() &gt; 0]!=0">
                                    <xsl:if test="//a1:component/a1:header/a1:publicationMeta/a1:numberingGroup/a1:numbering[@type='pageLast'][string-length() &gt; 0]!='no'">
                                        <end xmlns="http://www.loc.gov/mods/v3">
                                            <xsl:value-of select="normalize-space(//a1:component/a1:header/a1:publicationMeta/a1:numberingGroup/a1:numbering[@type='pageLast'])"/>
                                        </end>
                                    </xsl:if>
                                </xsl:if>
                                <xsl:if test="//a1:component/a1:header/a1:publicationMeta[@level='unit']/a1:countGroup/a1:count[@type='pageTotal']/@number[string-length() &gt; 0]!=0">
                                    <total xmlns="http://www.loc.gov/mods/v3">
                                        <xsl:value-of select="normalize-space(//a1:component/a1:header/a1:publicationMeta[@level='unit']/a1:countGroup/a1:count[@type='pageTotal']/@number)"/>
                                    </total>
                                </xsl:if>
                            </extent>
                    </part>
                </xsl:if>
            </relatedItem>
            <!-- Série antérieure -->
            <xsl:if test="//a1:header/a1:publicationMeta[@level='product']/a1:selfCitationGroup/a1:citation[@type='ancestor'][string-length() &gt; 0]">
                <relatedItem xmlns="http://www.loc.gov/mods/v3">
                    <xsl:attribute name="type">preceding</xsl:attribute>
                    <xsl:if test="//a1:header/a1:publicationMeta[@level='product']/a1:selfCitationGroup/a1:citation[@type='ancestor']/a1:journalTitle[string-length() &gt; 0]">
                        <titleInfo>
                            
                            <title>
                                <xsl:variable name="ttl">
                                    <xsl:apply-templates select="//a1:header/a1:publicationMeta[@level='product']/a1:selfCitationGroup/a1:citation[@type='ancestor']/a1:journalTitle"/>
                                </xsl:variable>
                                <xsl:value-of select="normalize-space($ttl)"/>
                            </title>
                        </titleInfo>
                    </xsl:if>
                    <xsl:if test="//a1:header/a1:publicationMeta[@level='product']/a1:selfCitationGroup/a1:citation[@type='ancestor']/a1:accessionId[string-length() &gt; 0]">
                        <xsl:for-each select="//a1:header/a1:publicationMeta[@level='product']/a1:selfCitationGroup/a1:citation[@type='ancestor']/a1:accessionId">
                        <identifier xmlns="http://www.loc.gov/mods/v3">
                            <xsl:attribute name="type">ISSN</xsl:attribute>
                            <xsl:value-of select="normalize-space(.)"/>
                        </identifier>
                        </xsl:for-each>
                    </xsl:if>
                    <xsl:if test="(//a1:header/a1:publicationMeta[@level='product']/a1:selfCitationGroup/a1:citation[@type='ancestor']/a1:pubYear | //a1:header/a1:publicationMeta[@level='product']/a1:selfCitationGroup/a1:citation[@type='ancestor']/a1:vol)[string-length() &gt; 0]">
                        <part xmlns="http://www.loc.gov/mods/v3">
                            <xsl:if test="//a1:header/a1:publicationMeta[@level='product']/a1:selfCitationGroup/a1:citation[@type='ancestor']/a1:pubYear[string-length() &gt; 0]">
                                <date xmlns="http://www.loc.gov/mods/v3">
                                    <xsl:attribute name="point">end</xsl:attribute>
                                    <xsl:value-of select="normalize-space(//a1:header/a1:publicationMeta[@level='product']/a1:selfCitationGroup/a1:citation[@type='ancestor']/a1:pubYear)"/>
                                </date>
                            </xsl:if>
                            <xsl:if test="//a1:header/a1:publicationMeta[@level='product']/a1:selfCitationGroup/a1:citation[@type='ancestor']/a1:vol[string-length() &gt; 0]">
                                <detail xmlns="http://www.loc.gov/mods/v3">
                                    <xsl:attribute name="type">volume</xsl:attribute>
                                    <caption xmlns="http://www.loc.gov/mods/v3">
                                        <xsl:text>last vol.</xsl:text>
                                    </caption>
                                    <number xmlns="http://www.loc.gov/mods/v3">
                                        <xsl:value-of select="normalize-space(//a1:header/a1:publicationMeta[@level='product']/a1:selfCitationGroup/a1:citation[@type='ancestor']/a1:vol)"/>
                                    </number>
                                </detail>
                            </xsl:if>
                            <xsl:if test="//a1:header/a1:publicationMeta[@level='product']/a1:selfCitationGroup/a1:citation[@type='ancestor']/a1:issue[string-length() &gt; 0]">
                                <detail xmlns="http://www.loc.gov/mods/v3">
                                    <xsl:attribute name="type">issue</xsl:attribute>
                                    <caption xmlns="http://www.loc.gov/mods/v3">
                                        <xsl:text>last no.</xsl:text>
                                    </caption>
                                    <number xmlns="http://www.loc.gov/mods/v3">
                                        <xsl:value-of select="normalize-space(//a1:header/a1:publicationMeta[@level='product']/a1:selfCitationGroup/a1:citation[@type='ancestor']/a1:issue)"/>
                                    </number>
                                </detail>
                            </xsl:if>
                        </part>
                    </xsl:if>
                </relatedItem>
            </xsl:if>
            <xsl:if test="//a1:component/a1:header/a1:contentMeta/a1:titleGroup/a1:title/a1:citation[string-length() &gt; 0]">
            <relatedItem xmlns="http://www.loc.gov/mods/v3">
                <xsl:attribute name="type">reviewOf</xsl:attribute>
                <xsl:choose>
                    <xsl:when test="//a1:component/a1:header/a1:contentMeta/a1:titleGroup/a1:title/a1:citation/a1:bookTitle[string-length() &gt; 0]">
                                <titleInfo xmlns="http://www.loc.gov/mods/v3">
                                    
                                    <title xmlns="http://www.loc.gov/mods/v3">
                                        <xsl:value-of select="normalize-space(//a1:component/a1:header/a1:contentMeta/a1:titleGroup/a1:title/a1:citation/a1:bookTitle)"/>
                                    </title>
                                </titleInfo>
                    </xsl:when>
                </xsl:choose>
                <xsl:if test="//a1:component/a1:header/a1:contentMeta/a1:titleGroup/a1:title/a1:citation/a1:author">
                        <xsl:for-each select="//a1:component/a1:header/a1:contentMeta/a1:titleGroup/a1:title/a1:citation/a1:author">
                            <xsl:call-template name="nameAut"/>
                        </xsl:for-each>
                </xsl:if>
                <xsl:if test="//a1:component/a1:header/a1:contentMeta/a1:titleGroup/a1:title/a1:citation/a1:publisherName[string-length() &gt; 0]">
                    <originInfo xmlns="http://www.loc.gov/mods/v3">
                            <publisher xmlns="http://www.loc.gov/mods/v3">
                                <xsl:for-each select="//a1:component/a1:header/a1:contentMeta/a1:titleGroup/a1:title/a1:citation/a1:publisherName">
                                    <xsl:value-of select="normalize-space(.)"/>
                                </xsl:for-each>
                            </publisher>
                        <xsl:if test="//a1:component/a1:header/a1:contentMeta/a1:titleGroup/a1:title/a1:citation/a1:publisherLoc">
                            <place xmlns="http://www.loc.gov/mods/v3">
                                <placeTerm xmlns="http://www.loc.gov/mods/v3">
                                    <xsl:attribute name="type">text</xsl:attribute>
                                    <xsl:variable name="norm">
                                        <xsl:apply-templates select="//a1:component/a1:header/a1:contentMeta/a1:titleGroup/a1:title/a1:citation/a1:publisherLoc"/>
                                    </xsl:variable>
                                    <xsl:value-of select="normalize-space($norm)"/>
                                </placeTerm>
                            </place>
                        </xsl:if>
                    </originInfo>
                </xsl:if>
                <xsl:if test="contains( //a1:component/a1:header/a1:contentMeta/a1:titleGroup/a1:title/a1:citation/a1:accessionId/@ref,'isbn')">
                    <identifier xmlns="http://www.loc.gov/mods/v3">
                        <xsl:attribute name="type">ISBN</xsl:attribute>
                        <xsl:value-of select="normalize-space(//a1:component/a1:header/a1:contentMeta/a1:titleGroup/a1:title/a1:citation/a1:accessionId)"/>
                    </identifier>
                </xsl:if>
                <xsl:if test="//a1:component/a1:header/a1:contentMeta/a1:titleGroup/a1:title/a1:citation/a1:pubYear[string-length() &gt; 0]">
                        <part xmlns="http://www.loc.gov/mods/v3">
                                <date xmlns="http://www.loc.gov/mods/v3">
                                    <xsl:value-of select="normalize-space(//a1:component/a1:header/a1:contentMeta/a1:titleGroup/a1:title/a1:citation/a1:pubYear)"/>
                                </date>
                            <xsl:if test="//a1:article/a1:front/a1:article-meta/a1:product/a1:page-range[string-length() &gt; 0]">
                                <extent xmlns="http://www.loc.gov/mods/v3">
                                    <xsl:attribute name="unit">pages</xsl:attribute>
                                    <list xmlns="http://www.loc.gov/mods/v3">
                                        <xsl:variable name="list">
                                            <xsl:apply-templates select="//a1:article/a1:front/a1:article-meta/a1:product/a1:page-range"/>
                                        </xsl:variable>
                                        <xsl:value-of select="normalize-space($list)"/>
                                    </list>
                                </extent>
                            </xsl:if>
                            <xsl:if test="//a1:article/a1:front/a1:article-meta/a1:product/a1:fpage[string-length() &gt; 0] and not(contains(//a1:article/a1:front/a1:article-meta/a1:product/a1:fpage,' '))">
                                <xsl:variable name="cptFpage">
                                    <xsl:value-of select="count(//a1:article/a1:front/a1:article-meta/a1:product/a1:fpage)"/>
                                </xsl:variable>
                                <xsl:if test="$cptFpage=1">
                                    <extent xmlns="http://www.loc.gov/mods/v3">
                                        <xsl:attribute name="unit">pages</xsl:attribute>
                                        <total xmlns="http://www.loc.gov/mods/v3">
                                            <xsl:value-of select="normalize-space(//a1:article/a1:front/a1:article-meta/a1:product/a1:fpage)"/>
                                        </total>
                                    </extent>
                                </xsl:if>
                            </xsl:if>
                        </part>
                </xsl:if>
            </relatedItem>
            </xsl:if>
            <!-- references / citations -->
            <xsl:if test="//a1:body/a1:bibliography">
                <xsl:if test="normalize-space(//a1:body/a1:bibliography/a1:bib/a1:citation)">
                <xsl:for-each select="//a1:body/a1:bibliography/a1:bib">
                    <xsl:if test="normalize-space(a1:citation)">
                <relatedItem xmlns="http://www.loc.gov/mods/v3">
                    <xsl:attribute name="type">isReferencedBy</xsl:attribute>
                    <xsl:if test="a1:citation/@xml:id[string-length() &gt; 0]">
                        <xsl:attribute name="displayLabel">
                            <xsl:value-of select="a1:citation/@xml:id"/>
                        </xsl:attribute>
                    </xsl:if>
                    <xsl:if test="a1:citation[string-length() &gt; 0]">
                        <xsl:for-each select="a1:citation">
                            <xsl:choose>
                                <xsl:when test="normalize-space(a1:articleTitle)">
                                    <titleInfo>
                                        
                                        <title>
                                            <xsl:variable name="ttl">
                                                <xsl:apply-templates select="a1:articleTitle "/>
                                            </xsl:variable>
                                            <xsl:value-of select="normalize-space($ttl)"/>
                                        </title>
                                    </titleInfo>
                                </xsl:when>
                                <xsl:when test="normalize-space(a1:chapterTitle)">
                                    <titleInfo>
                                        
                                        <title>
                                            <xsl:variable name="ttl">
                                                <xsl:apply-templates select="a1:chapterTitle"/>
                                            </xsl:variable>
                                            <xsl:value-of select="normalize-space($ttl)"/>
                                        </title>
                                    </titleInfo>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:choose>
                                        <xsl:when test="normalize-space(a1:journalTitle)">
                                            <titleInfo>
                                                
                                                <title>
                                                    <xsl:variable name="ttl">
                                                        <xsl:apply-templates select="a1:journalTitle"/>
                                                    </xsl:variable>
                                                    <xsl:value-of select="normalize-space($ttl)"/>
                                                </title>
                                            </titleInfo>
                                        </xsl:when>
                                        <xsl:otherwise>
                                            <xsl:variable name="ttl">
                                                <xsl:apply-templates select="."/>
                                            </xsl:variable>
                                            <xsl:if test="normalize-space($ttl)">
                                            <titleInfo>
                                                
                                                <title>
                                                    <xsl:value-of select="normalize-space($ttl)"/>
                                                </title>
                                            </titleInfo>
                                            </xsl:if>
                                        </xsl:otherwise>
                                    </xsl:choose>
                                </xsl:otherwise>
                            </xsl:choose>
                            <!-- Name -->
                            <xsl:if test="normalize-space(a1:author) and a1:articleTitle[string-length() &gt; 0] | a1:otherTitle[string-length() &gt; 0] | a1:chapterTitle[string-length() &gt; 0]">
                                <xsl:for-each select="a1:author">
                                    <xsl:call-template name="nameAut"/>
                                </xsl:for-each>
                            </xsl:if>
                            <!-- GroupName -->
                            <xsl:if test="a1:groupName[string-length() &gt; 0]">
                                <xsl:for-each select="a1:groupName">
                                    <name xmlns="http://www.loc.gov/mods/v3">
                                        <xsl:attribute name="type">corporate</xsl:attribute>
                                        <namePart xmlns="http://www.loc.gov/mods/v3">
                                            <xsl:value-of select="normalize-space(.)"/>
                                        </namePart>
                                    </name>
                                </xsl:for-each>
                            </xsl:if>
                            <!--  genre  -->
                            <xsl:if test="a1:journalTitle[string-length() &gt; 0]">
                                <genre xmlns="http://www.loc.gov/mods/v3">
                                    <xsl:text>journal article</xsl:text>
                                </genre>
                            </xsl:if>
                            <xsl:if test="a1:chapterTitle[string-length() &gt; 0]">
                                <genre xmlns="http://www.loc.gov/mods/v3">
                                    <xsl:text>book chapter</xsl:text>
                                </genre>
                            </xsl:if>
                            <xsl:variable name="bookVide">
                                <xsl:if test="normalize-space(a1:journalTitle | a1:bookTitle)">

                                </xsl:if>
                            </xsl:variable>
                            <xsl:if test="not(a1:journalTitle | a1:bookTitle)">
                                <xsl:if test="@type">
                                    <genre xmlns="http://www.loc.gov/mods/v3">
                                        <xsl:attribute name="authority">originalCategForm</xsl:attribute>
                                        <xsl:value-of select="@type"/>
                                    </genre>
                                </xsl:if>
                                <xsl:if test="a1:publisherName[string-length() &gt; 0]">
                                    <originInfo xmlns="http://www.loc.gov/mods/v3">
                                        <publisher xmlns="http://www.loc.gov/mods/v3">
                                            <xsl:variable name="norm">
                                                <xsl:apply-templates select="a1:publisherName"/>
                                            </xsl:variable>
                                            <xsl:value-of select="normalize-space($norm)"/>
                                        </publisher>
                                    </originInfo>
                                </xsl:if>
                                <xsl:if test="a1:pubYear/@year">
                                    <part xmlns="http://www.loc.gov/mods/v3">
                                        <date xmlns="http://www.loc.gov/mods/v3">
                                            <xsl:value-of select="normalize-space(a1:pubYear/@year)"/>
                                        </date>
                                    </part>
                                </xsl:if>
                            </xsl:if>
                            <xsl:if test="a1:journalTitle[string-length() &gt; 0] | a1:bookTitle[string-length() &gt; 0] and not(a1:articleTitle | a1:otherTitle | a1:chapterTitle)">
                                 
                                <xsl:if test="a1:author[string-length() &gt; 0] and not(a1:articleTitle | a1:otherTitle | a1:chapterTitle)">
                                    <xsl:for-each select="a1:author">
                                        <xsl:call-template name="nameAut"/>
                                        </xsl:for-each>
                                </xsl:if>
                                <xsl:if test="a1:editor[string-length() &gt; 0] and not(a1:articleTitle | a1:otherTitle | a1:chapterTitle)">
                                    <xsl:for-each select="a1:editor">
                                        <xsl:call-template name="nameEd"/>
                                    </xsl:for-each>
                                </xsl:if>
                                    <xsl:if test="a1:journalTitle[string-length() &gt; 0]">
                                        <genre xmlns="http://www.loc.gov/mods/v3">
                                            <xsl:text>journal</xsl:text>
                                        </genre>
                                    </xsl:if>
                                    <xsl:if test="a1:bookTitle[string-length() &gt; 0]">
                                        <genre xmlns="http://www.loc.gov/mods/v3">
                                            <xsl:text>book</xsl:text>
                                        </genre>
                                    </xsl:if>
                                    <xsl:if test="a1:publisherName[string-length() &gt; 0]">
                                        <originInfo xmlns="http://www.loc.gov/mods/v3">
                                            <publisher xmlns="http://www.loc.gov/mods/v3">
                                                <xsl:variable name="norm">
                                                    <xsl:apply-templates select="a1:publisherName"/>
                                                </xsl:variable>
                                                <xsl:value-of select="normalize-space($norm)"/>
                                            </publisher>
                                            <xsl:if test="a1:publisherLoc[string-length() &gt; 0]">
                                                <place xmlns="http://www.loc.gov/mods/v3">
                                                    <placeTerm xmlns="http://www.loc.gov/mods/v3">
                                                        <xsl:attribute name="type">text</xsl:attribute>
                                                        <xsl:variable name="norm">
                                                            <xsl:apply-templates select="a1:publisherLoc"/>
                                                        </xsl:variable>
                                                        <xsl:value-of select="normalize-space($norm)"/>
                                                    </placeTerm>
                                                </place>
                                            </xsl:if>
                                        </originInfo>
                                    </xsl:if>
                                    <xsl:if test="a1:pubYear[string-length() &gt; 0] | a1:vol[string-length() &gt; 0] | a1:issue[string-length() &gt; 0]
                                        | a1:pageFirst[string-length() &gt; 0] | a1:pageLast[string-length() &gt; 0]">
                                        <part xmlns="http://www.loc.gov/mods/v3">
                                            <xsl:if test="normalize-space(a1:pubYear)">
                                            <xsl:choose>
                                                <xsl:when test="a1:pubYear/@year[string-length() &gt; 0]">
                                                        <date xmlns="http://www.loc.gov/mods/v3">
                                                            <xsl:value-of select="normalize-space(a1:pubYear/@year)"/>
                                                        </date>
                                                </xsl:when>
                                                <xsl:otherwise>
                                                    <date xmlns="http://www.loc.gov/mods/v3">
                                                        <xsl:value-of select="normalize-space(a1:pubYear)"/>
                                                    </date>
                                                </xsl:otherwise>
                                            </xsl:choose>
                                            </xsl:if>
                                            <xsl:if test="a1:vol[string-length() &gt; 0]">
                                                <detail xmlns="http://www.loc.gov/mods/v3">
                                                    <xsl:attribute name="type">volume</xsl:attribute>
                                                    <caption xmlns="http://www.loc.gov/mods/v3">
                                                        <xsl:text>vol.</xsl:text>
                                                    </caption>
                                                    <number xmlns="http://www.loc.gov/mods/v3">
                                                        <xsl:value-of select="normalize-space(//a1:vol)"/>
                                                    </number>
                                                </detail>
                                            </xsl:if>
                                            <xsl:if test="a1:issue[string-length() &gt; 0]">
                                                <detail xmlns="http://www.loc.gov/mods/v3">
                                                    <xsl:attribute name="type">issue</xsl:attribute>
                                                    <caption xmlns="http://www.loc.gov/mods/v3">
                                                        <xsl:text>no.</xsl:text>
                                                    </caption>
                                                    <number xmlns="http://www.loc.gov/mods/v3">
                                                        <xsl:value-of select="normalize-space(//a1:issue)"/>
                                                    </number>
                                                </detail>
                                            </xsl:if>
                                            <xsl:if test="a1:pageFirst[string-length() &gt; 0] | a1:pageLast[string-length() &gt; 0]">
                                                <extent xmlns="http://www.loc.gov/mods/v3">
                                                    <xsl:attribute name="unit">pages</xsl:attribute>
                                                    <xsl:if test="a1:pageFirst !=0">
                                                        <start xmlns="http://www.loc.gov/mods/v3">
                                                            <xsl:value-of select="normalize-space(a1:pageFirst)"/>
                                                        </start>
                                                    </xsl:if>
                                                    <xsl:if test="a1:pageLast !=0">
                                                        <end xmlns="http://www.loc.gov/mods/v3">
                                                            <xsl:value-of select="normalize-space(a1:pageLast)"/>
                                                        </end>
                                                    </xsl:if>
                                                </extent>
                                            </xsl:if>
                                        </part>
                                    </xsl:if>
                            </xsl:if>
                            <xsl:if test="normalize-space(a1:journalTitle | a1:bookTitle) and a1:articleTitle[string-length() &gt; 0] | a1:otherTitle[string-length() &gt; 0] | a1:chapterTitle[string-length() &gt; 0]">
                                <relatedItem xmlns="http://www.loc.gov/mods/v3">
                                    <xsl:attribute name="type">host</xsl:attribute>
                                <titleInfo>
                                    
                                    <title>
                                        <xsl:variable name="norm">
                                            <xsl:apply-templates select="a1:journalTitle | a1:bookTitle"/>
                                        </xsl:variable>
                                        <xsl:value-of select="normalize-space($norm)"/>
                                    </title>
                                </titleInfo>
                                    <xsl:if test="a1:author[string-length() &gt; 0] and not(a1:articleTitle | a1:otherTitle | a1:chapterTitle)">
                                        <xsl:for-each select="a1:author">
                                                <xsl:call-template name="nameAut"/>
                                        </xsl:for-each>
                                    </xsl:if>
                                    <xsl:if test="a1:editor[string-length() &gt; 0] and not(a1:articleTitle | a1:otherTitle | a1:chapterTitle)">
                                        <xsl:for-each select="a1:editor">
                                           <xsl:call-template name="nameEd"/>
                                        </xsl:for-each>
                                    </xsl:if>
                                    <xsl:if test="a1:publisherName[string-length() &gt; 0]">
                                        <originInfo xmlns="http://www.loc.gov/mods/v3">
                                            <publisher xmlns="http://www.loc.gov/mods/v3">
                                                <xsl:variable name="norm">
                                                    <xsl:apply-templates select="a1:publisherName"/>
                                                </xsl:variable>
                                                <xsl:value-of select="normalize-space($norm)"/>
                                            </publisher>
                                            <xsl:if test="a1:publisherLoc[string-length() &gt; 0]">
                                                <place xmlns="http://www.loc.gov/mods/v3">
                                                    <placeTerm xmlns="http://www.loc.gov/mods/v3">
                                                        <xsl:attribute name="type">text</xsl:attribute>
                                                        <xsl:variable name="norm">
                                                            <xsl:apply-templates select="a1:publisherLoc"/>
                                                        </xsl:variable>
                                                        <xsl:value-of select="normalize-space($norm)"/>
                                                    </placeTerm>
                                                </place>
                                            </xsl:if>
                                        </originInfo>
                                    </xsl:if>
                                    <xsl:if test="a1:pubYear[string-length() &gt; 0] | a1:vol[string-length() &gt; 0] | a1:issue[string-length() &gt; 0]
                                        | a1:pageFirst[string-length() &gt; 0] | a1:pageLast[string-length() &gt; 0]">
                                        <part xmlns="http://www.loc.gov/mods/v3">
                                            <xsl:if test="a1:pubYear/@year[string-length() &gt; 0]">
                                            <date xmlns="http://www.loc.gov/mods/v3">
                                                <xsl:value-of select="normalize-space(a1:pubYear/@year)"/>
                                            </date>
                                            </xsl:if>
                                            <xsl:if test="a1:vol[string-length() &gt; 0]">
                                            <detail xmlns="http://www.loc.gov/mods/v3">
                                                <xsl:attribute name="type">volume</xsl:attribute>
                                                <caption xmlns="http://www.loc.gov/mods/v3">
                                                    <xsl:text>vol.</xsl:text>
                                                </caption>
                                                <number xmlns="http://www.loc.gov/mods/v3">
                                                    <xsl:value-of select="normalize-space(a1:vol)"/>
                                                </number>
                                            </detail>
                                            </xsl:if>
                                            <xsl:if test="a1:issue[string-length() &gt; 0]">
                                                <detail xmlns="http://www.loc.gov/mods/v3">
                                                    <xsl:attribute name="type">issue</xsl:attribute>
                                                    <caption xmlns="http://www.loc.gov/mods/v3">
                                                        <xsl:text>no.</xsl:text>
                                                    </caption>
                                                    <number xmlns="http://www.loc.gov/mods/v3">
                                                        <xsl:value-of select="normalize-space(a1:issue)"/>
                                                    </number>
                                                </detail>
                                            </xsl:if>
                                            <xsl:if test="a1:pageFirst[string-length() &gt; 0] | a1:pageLast[string-length() &gt; 0]">
                                            <extent xmlns="http://www.loc.gov/mods/v3">
                                                <xsl:attribute name="unit">pages</xsl:attribute>
                                                    <xsl:if test="a1:pageFirst !=0">
                                                        <start xmlns="http://www.loc.gov/mods/v3">
                                                            <xsl:value-of select="normalize-space(a1:pageFirst)"/>
                                                        </start>
                                                    </xsl:if>
                                                    <xsl:if test="a1:pageLast !=0">
                                                        <end xmlns="http://www.loc.gov/mods/v3">
                                                            <xsl:value-of select="normalize-space(a1:pageLast)"/>
                                                        </end>
                                                    </xsl:if>
                                            </extent>
                                            </xsl:if>
                                        </part>
                                    </xsl:if>
                                    </relatedItem>
                            </xsl:if>
                        </xsl:for-each>
                    </xsl:if>
                    <xsl:if test="//a1:header/a1:publicationMeta[@level='product']/a1:selfCitationGroup/a1:citation[@type='ancestor']/a1:accessionId[string-length() &gt; 0]">
                        <xsl:for-each select="//a1:header/a1:publicationMeta[@level='product']/a1:selfCitationGroup/a1:citation[@type='ancestor']/a1:accessionId">
                            <identifier xmlns="http://www.loc.gov/mods/v3">
                                <xsl:attribute name="type">ISSN</xsl:attribute>
                                <xsl:value-of select="normalize-space(.)"/>
                            </identifier>
                        </xsl:for-each>
                    </xsl:if>
                    <xsl:if test="(//a1:header/a1:publicationMeta[@level='product']/a1:selfCitationGroup/a1:citation[@type='ancestor']/a1:pubYear | //a1:header/a1:publicationMeta[@level='product']/a1:selfCitationGroup/a1:citation[@type='ancestor']/a1:vol)[string-length() &gt; 0]">
                        <part xmlns="http://www.loc.gov/mods/v3">
                            <xsl:if test="//a1:header/a1:publicationMeta[@level='product']/a1:selfCitationGroup/a1:citation[@type='ancestor']/a1:pubYear[string-length() &gt; 0]">
                                <date xmlns="http://www.loc.gov/mods/v3">
                                    <xsl:attribute name="point">end</xsl:attribute>
                                    <xsl:value-of select="normalize-space(//a1:header/a1:publicationMeta[@level='product']/a1:selfCitationGroup/a1:citation[@type='ancestor']/a1:pubYear)"/>
                                </date>
                            </xsl:if>
                            <xsl:if test="//a1:header/a1:publicationMeta[@level='product']/a1:selfCitationGroup/a1:citation[@type='ancestor']/a1:vol[string-length() &gt; 0]">
                                <detail xmlns="http://www.loc.gov/mods/v3">
                                    <xsl:attribute name="type">volume</xsl:attribute>
                                    <caption xmlns="http://www.loc.gov/mods/v3">
                                        <xsl:text>last vol.</xsl:text>
                                    </caption>
                                    <number xmlns="http://www.loc.gov/mods/v3">
                                        <xsl:value-of select="normalize-space(//a1:header/a1:publicationMeta[@level='product']/a1:selfCitationGroup/a1:citation[@type='ancestor']/a1:vol)"/>
                                    </number>
                                </detail>
                            </xsl:if>
                            <xsl:if test="//a1:header/a1:publicationMeta[@level='product']/a1:selfCitationGroup/a1:citation[@type='ancestor']/a1:issue[string-length() &gt; 0]">
                                <detail xmlns="http://www.loc.gov/mods/v3">
                                    <xsl:attribute name="type">issue</xsl:attribute>
                                    <caption xmlns="http://www.loc.gov/mods/v3">
                                        <xsl:text>last no.</xsl:text>
                                    </caption>
                                    <number xmlns="http://www.loc.gov/mods/v3">
                                        <xsl:value-of select="normalize-space(//a1:header/a1:publicationMeta[@level='product']/a1:selfCitationGroup/a1:citation[@type='ancestor']/a1:issue)"/>
                                    </number>
                                </detail>
                            </xsl:if>
                        </part>
                    </xsl:if>
                </relatedItem>
                    </xsl:if>
                </xsl:for-each>
                </xsl:if>
            </xsl:if>
            <!-- ******************* identifier ******************************-->
            <!-- Janvier 2014 - suite réunion J. Ducloy - identifiant utilisé par API web -->
            <xsl:if test="string-length($idistex) &gt; 0 ">
                <identifier xmlns="http://www.loc.gov/mods/v3">
                    <xsl:attribute name="type">istex</xsl:attribute>
                    <xsl:value-of select="$idistex"/>
                </identifier>
            </xsl:if>
            <xsl:if test="//a1:component/a1:header/a1:publicationMeta[@level='unit']/a1:doi[string-length() &gt; 0]">
                <identifier xmlns="http://www.loc.gov/mods/v3">
                    <xsl:attribute name="type">DOI</xsl:attribute>
                    <xsl:value-of select="normalize-space(//a1:component/a1:header/a1:publicationMeta[@level='unit']/a1:doi)"/>
                </identifier>
            </xsl:if>
            <xsl:if test="//a1:component/a1:header/a1:publicationMeta[@level='unit']/a1:idGroup/a1:id/@value[string-length() &gt; 0]">
                <identifier xmlns="http://www.loc.gov/mods/v3">
                    <xsl:attribute name="type">ArticleID</xsl:attribute>
                    <xsl:value-of select="normalize-space(//a1:component/a1:header/a1:publicationMeta[@level='unit']/a1:idGroup/a1:id/@value)"/>
                </identifier>
            </xsl:if>
            <!-- ****************************************** accessCondition niveau article *******************************-->
            <xsl:choose>
                <xsl:when test="//a1:legalStatement/a1:p[string-length() &gt; 0]">
                    <accessCondition>
                        <xsl:attribute name="type">use and reproduction</xsl:attribute>
                        <xsl:attribute name="contentType">
                            <xsl:value-of select="//a1:legalStatement/@type"/>
                        </xsl:attribute>
                        <xsl:variable name="norm">
                            <xsl:apply-templates select="//a1:legalStatement"/>
                        </xsl:variable>
                        <xsl:value-of select="normalize-space($norm)"/>
                    </accessCondition>
                </xsl:when>
                <xsl:when test="//a1:copyright[string-length() &gt; 0]">
                    <accessCondition>
                        <xsl:attribute name="type">use and reproduction</xsl:attribute>
                        <xsl:attribute name="contentType">
                           <xsl:text>copyright</xsl:text>
                        </xsl:attribute>
                        <xsl:variable name="cpy">
                            <xsl:apply-templates select="//a1:copyright"/>
                        </xsl:variable>
                        <xsl:value-of select="normalize-space($cpy)"/>
                    </accessCondition>
                </xsl:when>
            </xsl:choose>
            <!-- *************************************** RecordInfo niveau ouvrage *******************************************************-->
            <recordInfo xmlns="http://www.loc.gov/mods/v3">
                <xsl:if test="//a1:component/a1:header/a1:publicationMeta/a1:publisherInfo/a1:publisherName[string-length()&gt; 0]">
                    <recordOrigin xmlns="http://www.loc.gov/mods/v3">
                    <xsl:value-of select="normalize-space(//a1:component/a1:header/a1:publicationMeta/a1:publisherInfo/a1:publisherName)"/>
                    </recordOrigin>
                </xsl:if>
                <!-- ******************************************* Source ***************************************************************-->
                <recordContentSource xmlns="http://www.loc.gov/mods/v3">
                    <xsl:text>WILEY</xsl:text>
                </recordContentSource>
            </recordInfo>
        </mods>
    </xsl:template>
    <!--Fin  Traitement Principal -->
    <!-- Traitement de plusieurs affiliations dans 1 seul attribut "@affiliationRef" ex: "#ffj3188-aff-0001 #ffj3188-aff-0002" -->
    <xsl:template name="affiliation">
        <xsl:choose>
            <xsl:when test="@affiliationRef">
        <xsl:call-template name="tokenize"/>
        <xsl:call-template name="tokenizeCor"/>
        <xsl:call-template name="tokenizeCur"/>
        <xsl:call-template name="tokenizeNot"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:call-template name="affiliation2"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>

    <!--<xsl:variable name="cor" select="translate(@correspondenceRef,'#','')"/>
    <xsl:variable name="cur" select="translate(@currentRef ,'#','')"/>
    <xsl:variable name="not" select="translate(@noteRef ,'#','')"/>-->
    <xsl:template match="@affiliationRef" name="tokenize">
        <xsl:param name="text" select="@affiliationRef"/>
        <xsl:param name="separator" select="' '"/>
        <xsl:choose>
            <xsl:when test="not(contains($text, $separator))">
                <xsl:variable name="aff">
                    <xsl:value-of select="translate($text,'#','')"/>
                </xsl:variable>
                <xsl:if test="normalize-space(//a1:affiliation[@xml:id=$aff])">
                    <affiliation xmlns="http://www.loc.gov/mods/v3">
                        <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:orgDiv[string-length() &gt; 0 ]">
                            <xsl:for-each select="//a1:affiliation[@xml:id=$aff]/a1:orgDiv">
                                <xsl:variable name="aff2">
                                    <xsl:apply-templates select="."/>
                                </xsl:variable>
                                <xsl:value-of select="normalize-space($aff2)"/>
                                <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:orgName[string-length() &gt; 0 ] | //a1:affiliation[@xml:id=$aff]/a1:address/a1:street[string-length() &gt; 0 ] | //a1:affiliation[@xml:id=$aff]/a1:address/a1:countryPart[string-length() &gt; 0 ]
                                    | //a1:affiliation[@xml:id=$aff]/a1:address/a1:postCode[string-length() &gt; 0 ] | //a1:affiliation[@xml:id=$aff]/a1:address/a1:city[string-length() &gt; 0 ]| //a1:affiliation[@xml:id=$aff]/a1:address/a1:state[string-length() &gt; 0 ]| //a1:affiliation[@xml:id=$aff]/a1:address/a1:country[string-length() &gt; 0 ]">
                                    <xsl:text>, </xsl:text>
                                </xsl:if>
                            </xsl:for-each>
                        </xsl:if>
                        <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:orgName[string-length() &gt; 0 ]">
                            <xsl:for-each select="//a1:affiliation[@xml:id=$aff]/a1:orgName">
                                <xsl:variable name="aff2">
                                    <xsl:apply-templates select="."/>
                                </xsl:variable>
                                <xsl:value-of select="normalize-space($aff2)"/>
                                <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:address/a1:street[string-length() &gt; 0 ] | //a1:affiliation[@xml:id=$aff]/a1:address/a1:countryPart[string-length() &gt; 0 ]
                                    | //a1:affiliation[@xml:id=$aff]/a1:address/a1:postCode[string-length() &gt; 0 ] | //a1:affiliation[@xml:id=$aff]/a1:address/a1:city[string-length() &gt; 0 ]| //a1:affiliation[@xml:id=$aff]/a1:address/a1:state[string-length() &gt; 0 ]| //a1:affiliation[@xml:id=$aff]/a1:address/a1:country[string-length() &gt; 0 ]">
                                    <xsl:text>, </xsl:text>
                                </xsl:if>
                            </xsl:for-each>
                        </xsl:if>
                        <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:address/a1:street[string-length() &gt; 0 ]">
                            <xsl:variable name="aff2">
                                <xsl:apply-templates select="//a1:affiliation[@xml:id=$aff]/a1:address/a1:street"/>
                            </xsl:variable>
                            <xsl:value-of select="normalize-space($aff2)"/>
                            <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:address/a1:countryPart[string-length() &gt; 0 ]
                                | //a1:affiliation[@xml:id=$aff]/a1:address/a1:postCode[string-length() &gt; 0 ] | //a1:affiliation[@xml:id=$aff]/a1:address/a1:city[string-length() &gt; 0 ]| //a1:affiliation[@xml:id=$aff]/a1:address/a1:state[string-length() &gt; 0 ]| //a1:affiliation[@xml:id=$aff]/a1:address/a1:country[string-length() &gt; 0 ]">
                                <xsl:text>, </xsl:text>
                            </xsl:if>
                        </xsl:if>
                        <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:address/a1:countryPart[string-length() &gt; 0 ]">
                            <xsl:variable name="aff2">
                                <xsl:apply-templates select="//a1:affiliation[@xml:id=$aff]/a1:address/a1:countryPart"/>
                            </xsl:variable>
                            <xsl:value-of select="normalize-space($aff2)"/>
                            <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:address/a1:postCode[string-length() &gt; 0 ] | //a1:affiliation[@xml:id=$aff]/a1:address/a1:city[string-length() &gt; 0 ]| //a1:affiliation[@xml:id=$aff]/a1:address/a1:state[string-length() &gt; 0 ]| //a1:affiliation[@xml:id=$aff]/a1:address/a1:country[string-length() &gt; 0 ]">
                                <xsl:text>, </xsl:text>
                            </xsl:if>
                        </xsl:if>
                        <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:address/a1:postCode[string-length() &gt; 0 ]">
                            <xsl:variable name="aff2">
                                <xsl:apply-templates select="//a1:affiliation[@xml:id=$aff]/a1:address/a1:postCode"/>
                            </xsl:variable>
                            <xsl:value-of select="normalize-space($aff2)"/>
                            <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:address/a1:city[string-length() &gt; 0 ]| //a1:affiliation[@xml:id=$aff]/a1:address/a1:state[string-length() &gt; 0 ]| //a1:affiliation[@xml:id=$aff]/a1:address/a1:country[string-length() &gt; 0 ]">
                                <xsl:text>, </xsl:text>
                            </xsl:if>
                        </xsl:if>
                        <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:address/a1:city[string-length() &gt; 0 ]">
                            <xsl:variable name="aff2">
                                <xsl:apply-templates select="//a1:affiliation[@xml:id=$aff]/a1:address/a1:city"/>
                            </xsl:variable>
                            <xsl:value-of select="normalize-space($aff2)"/>
                            <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:address/a1:state[string-length() &gt; 0 ]| //a1:affiliation[@xml:id=$aff]/a1:address/a1:country[string-length() &gt; 0 ]">
                                <xsl:text>, </xsl:text>
                            </xsl:if>
                        </xsl:if>
                        <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:address/a1:state[string-length() &gt; 0 ]">
                            <xsl:variable name="aff2">
                                <xsl:apply-templates select="//a1:affiliation[@xml:id=$aff]/a1:address/a1:state"/>
                            </xsl:variable>
                            <xsl:value-of select="normalize-space($aff2)"/>
                            <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:address/a1:country[string-length() &gt; 0 ]">
                                <xsl:text>, </xsl:text>
                            </xsl:if>
                        </xsl:if>
                        <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:address/a1:country[string-length() &gt; 0 ]">
                            <xsl:variable name="aff2">
                                <xsl:apply-templates select="//a1:affiliation[@xml:id=$aff]/a1:address/a1:country"/>
                            </xsl:variable>
                            <xsl:value-of select="normalize-space($aff2)"/>
                        </xsl:if>
                        <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:unparsedAffiliation[string-length() &gt; 0 ]">
                            <xsl:variable name="aff2">
                                <xsl:apply-templates select="//a1:affiliation[@xml:id=$aff]/a1:unparsedAffiliation"/>
                            </xsl:variable>
                            <xsl:value-of select="normalize-space($aff2)"/>
                        </xsl:if>
                    </affiliation>
                </xsl:if>
            </xsl:when>
            <xsl:otherwise>
                <affiliation xmlns="http://www.loc.gov/mods/v3">
                    <xsl:variable name="translate">
                        <xsl:value-of select="translate($text,'#','')"/>
                    </xsl:variable>
                    <xsl:variable name="aff">
                        <xsl:value-of select="normalize-space(substring-before($translate, $separator))"/>
                    </xsl:variable>
                    <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:orgDiv[string-length() &gt; 0 ]">
                        <xsl:for-each select="//a1:affiliation[@xml:id=$aff]/a1:orgDiv">
                            <xsl:variable name="aff2">
                                <xsl:apply-templates select="."/>
                            </xsl:variable>
                            <xsl:value-of select="normalize-space($aff2)"/>
                            <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:orgName[string-length() &gt; 0 ] | //a1:affiliation[@xml:id=$aff]/a1:address/a1:street[string-length() &gt; 0 ] | //a1:affiliation[@xml:id=$aff]/a1:address/a1:countryPart[string-length() &gt; 0 ]
                                | //a1:affiliation[@xml:id=$aff]/a1:address/a1:postCode[string-length() &gt; 0 ] | //a1:affiliation[@xml:id=$aff]/a1:address/a1:city[string-length() &gt; 0 ]| //a1:affiliation[@xml:id=$aff]/a1:address/a1:state[string-length() &gt; 0 ]| //a1:affiliation[@xml:id=$aff]/a1:address/a1:country[string-length() &gt; 0 ]">
                                <xsl:text>, </xsl:text>
                            </xsl:if>
                        </xsl:for-each>
                    </xsl:if>
                    <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:orgName[string-length() &gt; 0 ]">
                        <xsl:for-each select="//a1:affiliation[@xml:id=$aff]/a1:orgName">
                            <xsl:variable name="aff2">
                                <xsl:apply-templates select="."/>
                            </xsl:variable>
                            <xsl:value-of select="normalize-space($aff2)"/>
                            <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:address/a1:street[string-length() &gt; 0 ] | //a1:affiliation[@xml:id=$aff]/a1:address/a1:countryPart[string-length() &gt; 0 ]
                                | //a1:affiliation[@xml:id=$aff]/a1:address/a1:postCode[string-length() &gt; 0 ] | //a1:affiliation[@xml:id=$aff]/a1:address/a1:city[string-length() &gt; 0 ]| //a1:affiliation[@xml:id=$aff]/a1:address/a1:state[string-length() &gt; 0 ]| //a1:affiliation[@xml:id=$aff]/a1:address/a1:country[string-length() &gt; 0 ]">
                                <xsl:text>, </xsl:text>
                            </xsl:if>
                        </xsl:for-each>
                    </xsl:if>
                    <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:address/a1:street[string-length() &gt; 0 ]">
                        <xsl:variable name="aff2">
                            <xsl:apply-templates select="//a1:affiliation[@xml:id=$aff]/a1:address/a1:street"/>
                        </xsl:variable>
                        <xsl:value-of select="normalize-space($aff2)"/>
                        <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:address/a1:countryPart[string-length() &gt; 0 ]
                            | //a1:affiliation[@xml:id=$aff]/a1:address/a1:postCode[string-length() &gt; 0 ] | //a1:affiliation[@xml:id=$aff]/a1:address/a1:city[string-length() &gt; 0 ]| //a1:affiliation[@xml:id=$aff]/a1:address/a1:state[string-length() &gt; 0 ]| //a1:affiliation[@xml:id=$aff]/a1:address/a1:country[string-length() &gt; 0 ]">
                            <xsl:text>, </xsl:text>
                        </xsl:if>
                    </xsl:if>
                    <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:address/a1:postCode[string-length() &gt; 0 ]">
                        <xsl:variable name="aff2">
                            <xsl:apply-templates select="//a1:affiliation[@xml:id=$aff]/a1:address/a1:postCode"/>
                        </xsl:variable>
                        <xsl:value-of select="normalize-space($aff2)"/>
                        <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:address/a1:city[string-length() &gt; 0 ]| //a1:affiliation[@xml:id=$aff]/a1:address/a1:state[string-length() &gt; 0 ]| //a1:affiliation[@xml:id=$aff]/a1:address/a1:country[string-length() &gt; 0 ]">
                            <xsl:text>, </xsl:text>
                        </xsl:if>
                    </xsl:if>
                    <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:address/a1:city[string-length() &gt; 0 ]">
                        <xsl:variable name="aff2">
                            <xsl:apply-templates select="//a1:affiliation[@xml:id=$aff]/a1:address/a1:city"/>
                        </xsl:variable>
                        <xsl:value-of select="normalize-space($aff2)"/>
                        <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:address/a1:countryPart[string-length() &gt; 0 ] |//a1:affiliation[@xml:id=$aff]/a1:address/a1:state[string-length() &gt; 0 ]| //a1:affiliation[@xml:id=$aff]/a1:address/a1:country[string-length() &gt; 0 ]">
                            <xsl:text>, </xsl:text>
                        </xsl:if>
                    </xsl:if>
                    <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:address/a1:countryPart[string-length() &gt; 0 ]">
                        <xsl:variable name="aff2">
                            <xsl:apply-templates select="//a1:affiliation[@xml:id=$aff]/a1:address/a1:countryPart"/>
                        </xsl:variable>
                        <xsl:value-of select="normalize-space($aff2)"/>
                        <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:address/a1:state[string-length() &gt; 0 ]| //a1:affiliation[@xml:id=$aff]/a1:address/a1:country[string-length() &gt; 0 ]">
                            <xsl:text>, </xsl:text>
                        </xsl:if>
                    </xsl:if>
                    <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:address/a1:state[string-length() &gt; 0 ]">
                        <xsl:variable name="aff2">
                            <xsl:apply-templates select="//a1:affiliation[@xml:id=$aff]/a1:address/a1:state"/>
                        </xsl:variable>
                        <xsl:value-of select="normalize-space($aff2)"/>
                        <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:address/a1:country[string-length() &gt; 0 ]">
                            <xsl:text>, </xsl:text>
                        </xsl:if>
                    </xsl:if>
                    <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:address/a1:country[string-length() &gt; 0 ]">
                        <xsl:variable name="aff2">
                            <xsl:apply-templates select="//a1:affiliation[@xml:id=$aff]/a1:address/a1:country"/>
                        </xsl:variable>
                        <xsl:value-of select="normalize-space($aff2)"/>
                    </xsl:if>
                    <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:unparsedAffiliation[string-length() &gt; 0 ]">
                        <xsl:variable name="aff2">
                            <xsl:apply-templates select="//a1:affiliation[@xml:id=$aff]/a1:unparsedAffiliation"/>
                        </xsl:variable>
                        <xsl:value-of select="normalize-space($aff2)"/>
                    </xsl:if>
                </affiliation>
                <xsl:call-template name="tokenize">
                    <xsl:with-param name="text" select="substring-after($text, $separator)"/>
                </xsl:call-template>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    <xsl:template match="@correspondenceRef" name="tokenizeCor">
        <xsl:param name="text" select="@correspondenceRef"/>
        <xsl:param name="separator" select="' '"/>
        <xsl:choose>
            <xsl:when test="not(contains($text, $separator))">
                <xsl:variable name="aff">
                    <xsl:value-of select="translate($text,'#','')"/>
                </xsl:variable>
                <xsl:if test="//a1:affiliation[@xml:id=$aff]">
                    <description xmlns="http://www.loc.gov/mods/v3">
                        <xsl:text>Correspondence address: </xsl:text>
                        <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:orgDiv[string-length() &gt; 0 ]">
                            <xsl:for-each select="//a1:affiliation[@xml:id=$aff]/a1:orgDiv">
                                <xsl:variable name="aff2">
                                    <xsl:apply-templates select="."/>
                                </xsl:variable>
                                <xsl:value-of select="normalize-space($aff2)"/>
                                <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:orgName[string-length() &gt; 0 ] | //a1:affiliation[@xml:id=$aff]/a1:address/a1:street[string-length() &gt; 0 ] | //a1:affiliation[@xml:id=$aff]/a1:address/a1:countryPart[string-length() &gt; 0 ]
                                    | //a1:affiliation[@xml:id=$aff]/a1:address/a1:postCode[string-length() &gt; 0 ] | //a1:affiliation[@xml:id=$aff]/a1:address/a1:city[string-length() &gt; 0 ]| //a1:affiliation[@xml:id=$aff]/a1:address/a1:state[string-length() &gt; 0 ]| //a1:affiliation[@xml:id=$aff]/a1:address/a1:country[string-length() &gt; 0 ]">
                                    <xsl:text>, </xsl:text>
                                </xsl:if>
                            </xsl:for-each>
                        </xsl:if>
                        <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:orgName[string-length() &gt; 0 ]">
                            <xsl:for-each select="//a1:affiliation[@xml:id=$aff]/a1:orgName">
                                <xsl:variable name="aff2">
                                    <xsl:apply-templates select="."/>
                                </xsl:variable>
                                <xsl:value-of select="normalize-space($aff2)"/>
                                <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:address/a1:street[string-length() &gt; 0 ] | //a1:affiliation[@xml:id=$aff]/a1:address/a1:countryPart[string-length() &gt; 0 ]
                                    | //a1:affiliation[@xml:id=$aff]/a1:address/a1:postCode[string-length() &gt; 0 ] | //a1:affiliation[@xml:id=$aff]/a1:address/a1:city[string-length() &gt; 0 ]| //a1:affiliation[@xml:id=$aff]/a1:address/a1:state[string-length() &gt; 0 ]| //a1:affiliation[@xml:id=$aff]/a1:address/a1:country[string-length() &gt; 0 ]">
                                    <xsl:text>, </xsl:text>
                                </xsl:if>
                            </xsl:for-each>
                        </xsl:if>
                        <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:address/a1:street[string-length() &gt; 0 ]">
                            <xsl:variable name="aff2">
                                <xsl:apply-templates select="//a1:affiliation[@xml:id=$aff]/a1:address/a1:street"/>
                            </xsl:variable>
                            <xsl:value-of select="normalize-space($aff2)"/>
                            <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:address/a1:countryPart[string-length() &gt; 0 ]
                                | //a1:affiliation[@xml:id=$aff]/a1:address/a1:postCode[string-length() &gt; 0 ] | //a1:affiliation[@xml:id=$aff]/a1:address/a1:city[string-length() &gt; 0 ]| //a1:affiliation[@xml:id=$aff]/a1:address/a1:state[string-length() &gt; 0 ]| //a1:affiliation[@xml:id=$aff]/a1:address/a1:country[string-length() &gt; 0 ]">
                                <xsl:text>, </xsl:text>
                            </xsl:if>
                        </xsl:if>
                        <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:address/a1:countryPart[string-length() &gt; 0 ]">
                            <xsl:variable name="aff2">
                                <xsl:apply-templates select="//a1:affiliation[@xml:id=$aff]/a1:address/a1:countryPart"/>
                            </xsl:variable>
                            <xsl:value-of select="normalize-space($aff2)"/>
                            <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:address/a1:postCode[string-length() &gt; 0 ] | //a1:affiliation[@xml:id=$aff]/a1:address/a1:city[string-length() &gt; 0 ]| //a1:affiliation[@xml:id=$aff]/a1:address/a1:state[string-length() &gt; 0 ]| //a1:affiliation[@xml:id=$aff]/a1:address/a1:country[string-length() &gt; 0 ]">
                                <xsl:text>, </xsl:text>
                            </xsl:if>
                        </xsl:if>
                        <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:address/a1:postCode[string-length() &gt; 0 ]">
                            <xsl:variable name="aff2">
                                <xsl:apply-templates select="//a1:affiliation[@xml:id=$aff]/a1:address/a1:postCode"/>
                            </xsl:variable>
                            <xsl:value-of select="normalize-space($aff2)"/>
                            <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:address/a1:city[string-length() &gt; 0 ]| //a1:affiliation[@xml:id=$aff]/a1:address/a1:state[string-length() &gt; 0 ]| //a1:affiliation[@xml:id=$aff]/a1:address/a1:country[string-length() &gt; 0 ]">
                                <xsl:text>, </xsl:text>
                            </xsl:if>
                        </xsl:if>
                        <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:address/a1:city[string-length() &gt; 0 ]">
                            <xsl:variable name="aff2">
                                <xsl:apply-templates select="//a1:affiliation[@xml:id=$aff]/a1:address/a1:city"/>
                            </xsl:variable>
                            <xsl:value-of select="normalize-space($aff2)"/>
                            <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:address/a1:state[string-length() &gt; 0 ]| //a1:affiliation[@xml:id=$aff]/a1:address/a1:country[string-length() &gt; 0 ]">
                                <xsl:text>, </xsl:text>
                            </xsl:if>
                        </xsl:if>
                        <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:address/a1:state[string-length() &gt; 0 ]">
                            <xsl:variable name="aff2">
                                <xsl:apply-templates select="//a1:affiliation[@xml:id=$aff]/a1:address/a1:state"/>
                            </xsl:variable>
                            <xsl:value-of select="normalize-space($aff2)"/>
                            <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:address/a1:country[string-length() &gt; 0 ]">
                                <xsl:text>, </xsl:text>
                            </xsl:if>
                        </xsl:if>
                        <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:address/a1:country[string-length() &gt; 0 ]">
                            <xsl:variable name="aff2">
                                <xsl:apply-templates select="//a1:affiliation[@xml:id=$aff]/a1:address/a1:country"/>
                            </xsl:variable>
                            <xsl:value-of select="normalize-space($aff2)"/>
                        </xsl:if>
                        <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:unparsedAffiliation[string-length() &gt; 0 ]">
                            <xsl:variable name="aff2">
                                <xsl:apply-templates select="//a1:affiliation[@xml:id=$aff]/a1:unparsedAffiliation"/>
                            </xsl:variable>
                            <xsl:value-of select="normalize-space($aff2)"/>
                        </xsl:if>
                    </description>
                </xsl:if>
            </xsl:when>
            <xsl:otherwise>
                <affiliation xmlns="http://www.loc.gov/mods/v3">
                    <xsl:text>Correspondence address: </xsl:text>
                    <xsl:variable name="translate">
                        <xsl:value-of select="translate($text,'#','')"/>
                    </xsl:variable>
                    <xsl:variable name="aff">
                        <xsl:value-of select="normalize-space(substring-before($translate, $separator))"/>
                    </xsl:variable>
                    <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:orgDiv[string-length() &gt; 0 ]">
                        <xsl:for-each select="//a1:affiliation[@xml:id=$aff]/a1:orgDiv">
                            <xsl:variable name="aff2">
                                <xsl:apply-templates select="."/>
                            </xsl:variable>
                            <xsl:value-of select="normalize-space($aff2)"/>
                            <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:orgName[string-length() &gt; 0 ] | //a1:affiliation[@xml:id=$aff]/a1:address/a1:street[string-length() &gt; 0 ] | //a1:affiliation[@xml:id=$aff]/a1:address/a1:countryPart[string-length() &gt; 0 ]
                                | //a1:affiliation[@xml:id=$aff]/a1:address/a1:postCode[string-length() &gt; 0 ] | //a1:affiliation[@xml:id=$aff]/a1:address/a1:city[string-length() &gt; 0 ]| //a1:affiliation[@xml:id=$aff]/a1:address/a1:state[string-length() &gt; 0 ]| //a1:affiliation[@xml:id=$aff]/a1:address/a1:country[string-length() &gt; 0 ]">
                                <xsl:text>, </xsl:text>
                            </xsl:if>
                        </xsl:for-each>
                    </xsl:if>
                    <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:orgName[string-length() &gt; 0 ]">
                        <xsl:for-each select="//a1:affiliation[@xml:id=$aff]/a1:orgName">
                            <xsl:variable name="aff2">
                                <xsl:apply-templates select="."/>
                            </xsl:variable>
                            <xsl:value-of select="normalize-space($aff2)"/>
                            <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:address/a1:street[string-length() &gt; 0 ] | //a1:affiliation[@xml:id=$aff]/a1:address/a1:countryPart[string-length() &gt; 0 ]
                                | //a1:affiliation[@xml:id=$aff]/a1:address/a1:postCode[string-length() &gt; 0 ] | //a1:affiliation[@xml:id=$aff]/a1:address/a1:city[string-length() &gt; 0 ]| //a1:affiliation[@xml:id=$aff]/a1:address/a1:state[string-length() &gt; 0 ]| //a1:affiliation[@xml:id=$aff]/a1:address/a1:country[string-length() &gt; 0 ]">
                                <xsl:text>, </xsl:text>
                            </xsl:if>
                        </xsl:for-each>
                    </xsl:if>
                    <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:address/a1:street[string-length() &gt; 0 ]">
                        <xsl:variable name="aff2">
                            <xsl:apply-templates select="//a1:affiliation[@xml:id=$aff]/a1:address/a1:street"/>
                        </xsl:variable>
                        <xsl:value-of select="normalize-space($aff2)"/>
                        <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:address/a1:countryPart[string-length() &gt; 0 ]
                            | //a1:affiliation[@xml:id=$aff]/a1:address/a1:postCode[string-length() &gt; 0 ] | //a1:affiliation[@xml:id=$aff]/a1:address/a1:city[string-length() &gt; 0 ]| //a1:affiliation[@xml:id=$aff]/a1:address/a1:state[string-length() &gt; 0 ]| //a1:affiliation[@xml:id=$aff]/a1:address/a1:country[string-length() &gt; 0 ]">
                            <xsl:text>, </xsl:text>
                        </xsl:if>
                    </xsl:if>
                    <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:address/a1:countryPart[string-length() &gt; 0 ]">
                        <xsl:variable name="aff2">
                            <xsl:apply-templates select="//a1:affiliation[@xml:id=$aff]/a1:address/a1:countryPart"/>
                        </xsl:variable>
                        <xsl:value-of select="normalize-space($aff2)"/>
                        <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:address/a1:postCode[string-length() &gt; 0 ] | //a1:affiliation[@xml:id=$aff]/a1:address/a1:city[string-length() &gt; 0 ]| //a1:affiliation[@xml:id=$aff]/a1:address/a1:state[string-length() &gt; 0 ]| //a1:affiliation[@xml:id=$aff]/a1:address/a1:country[string-length() &gt; 0 ]">
                            <xsl:text>, </xsl:text>
                        </xsl:if>
                    </xsl:if>
                    <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:address/a1:postCode[string-length() &gt; 0 ]">
                        <xsl:variable name="aff2">
                            <xsl:apply-templates select="//a1:affiliation[@xml:id=$aff]/a1:address/a1:postCode"/>
                        </xsl:variable>
                        <xsl:value-of select="normalize-space($aff2)"/>
                        <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:address/a1:city[string-length() &gt; 0 ]| //a1:affiliation[@xml:id=$aff]/a1:address/a1:state[string-length() &gt; 0 ]| //a1:affiliation[@xml:id=$aff]/a1:address/a1:country[string-length() &gt; 0 ]">
                            <xsl:text>, </xsl:text>
                        </xsl:if>
                    </xsl:if>
                    <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:address/a1:city[string-length() &gt; 0 ]">
                        <xsl:variable name="aff2">
                            <xsl:apply-templates select="//a1:affiliation[@xml:id=$aff]/a1:address/a1:city"/>
                        </xsl:variable>
                        <xsl:value-of select="normalize-space($aff2)"/>
                        <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:address/a1:state[string-length() &gt; 0 ]| //a1:affiliation[@xml:id=$aff]/a1:address/a1:country[string-length() &gt; 0 ]">
                            <xsl:text>, </xsl:text>
                        </xsl:if>
                    </xsl:if>
                    <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:address/a1:state[string-length() &gt; 0 ]">
                        <xsl:variable name="aff2">
                            <xsl:apply-templates select="//a1:affiliation[@xml:id=$aff]/a1:address/a1:state"/>
                        </xsl:variable>
                        <xsl:value-of select="normalize-space($aff2)"/>
                        <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:address/a1:country[string-length() &gt; 0 ]">
                            <xsl:text>, </xsl:text>
                        </xsl:if>
                    </xsl:if>
                    <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:address/a1:country[string-length() &gt; 0 ]">
                        <xsl:variable name="aff2">
                            <xsl:apply-templates select="//a1:affiliation[@xml:id=$aff]/a1:address/a1:country"/>
                        </xsl:variable>
                        <xsl:value-of select="normalize-space($aff2)"/>
                    </xsl:if>
                    <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:unparsedAffiliation[string-length() &gt; 0 ]">
                        <xsl:variable name="aff2">
                            <xsl:apply-templates select="//a1:affiliation[@xml:id=$aff]/a1:unparsedAffiliation"/>
                        </xsl:variable>
                        <xsl:value-of select="normalize-space($aff2)"/>
                    </xsl:if>
                </affiliation>
                <xsl:call-template name="tokenizeCor">
                    <xsl:with-param name="text" select="substring-after($text, $separator)"/>
                </xsl:call-template>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    <xsl:template match="@currentRef" name="tokenizeCur">
        <xsl:param name="text" select="@currentRef"/>
        <xsl:param name="separator" select="' '"/>
        <xsl:choose>
            <xsl:when test="not(contains($text, $separator))">
                <xsl:variable name="aff">
                    <xsl:value-of select="translate($text,'#','')"/>
                </xsl:variable>
                <xsl:if test="//a1:affiliation[@xml:id=$aff]">
                    <affiliation xmlns="http://www.loc.gov/mods/v3">
                        <xsl:text>Current Address: </xsl:text>
                        <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:orgDiv[string-length() &gt; 0 ]">
                            <xsl:for-each select="//a1:affiliation[@xml:id=$aff]/a1:orgDiv">
                                <xsl:variable name="aff2">
                                    <xsl:apply-templates select="."/>
                                </xsl:variable>
                                <xsl:value-of select="normalize-space($aff2)"/>
                                <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:orgName[string-length() &gt; 0 ] | //a1:affiliation[@xml:id=$aff]/a1:address/a1:street[string-length() &gt; 0 ] | //a1:affiliation[@xml:id=$aff]/a1:address/a1:countryPart[string-length() &gt; 0 ]
                                    | //a1:affiliation[@xml:id=$aff]/a1:address/a1:postCode[string-length() &gt; 0 ] | //a1:affiliation[@xml:id=$aff]/a1:address/a1:city[string-length() &gt; 0 ]| //a1:affiliation[@xml:id=$aff]/a1:address/a1:state[string-length() &gt; 0 ]| //a1:affiliation[@xml:id=$aff]/a1:address/a1:country[string-length() &gt; 0 ]">
                                    <xsl:text>, </xsl:text>
                                </xsl:if>
                            </xsl:for-each>
                        </xsl:if>
                        <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:orgName[string-length() &gt; 0 ]">
                            <xsl:for-each select="//a1:affiliation[@xml:id=$aff]/a1:orgName">
                                <xsl:variable name="aff2">
                                    <xsl:apply-templates select="."/>
                                </xsl:variable>
                                <xsl:value-of select="normalize-space($aff2)"/>
                                <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:address/a1:street[string-length() &gt; 0 ] | //a1:affiliation[@xml:id=$aff]/a1:address/a1:countryPart[string-length() &gt; 0 ]
                                    | //a1:affiliation[@xml:id=$aff]/a1:address/a1:postCode[string-length() &gt; 0 ] | //a1:affiliation[@xml:id=$aff]/a1:address/a1:city[string-length() &gt; 0 ]| //a1:affiliation[@xml:id=$aff]/a1:address/a1:state[string-length() &gt; 0 ]| //a1:affiliation[@xml:id=$aff]/a1:address/a1:country[string-length() &gt; 0 ]">
                                    <xsl:text>, </xsl:text>
                                </xsl:if>
                            </xsl:for-each>
                        </xsl:if>
                        <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:address/a1:street[string-length() &gt; 0 ]">
                            <xsl:variable name="aff2">
                                <xsl:apply-templates select="//a1:affiliation[@xml:id=$aff]/a1:address/a1:street"/>
                            </xsl:variable>
                            <xsl:value-of select="normalize-space($aff2)"/>
                            <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:address/a1:countryPart[string-length() &gt; 0 ]
                                | //a1:affiliation[@xml:id=$aff]/a1:address/a1:postCode[string-length() &gt; 0 ] | //a1:affiliation[@xml:id=$aff]/a1:address/a1:city[string-length() &gt; 0 ]| //a1:affiliation[@xml:id=$aff]/a1:address/a1:state[string-length() &gt; 0 ]| //a1:affiliation[@xml:id=$aff]/a1:address/a1:country[string-length() &gt; 0 ]">
                                <xsl:text>, </xsl:text>
                            </xsl:if>
                        </xsl:if>
                        <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:address/a1:countryPart[string-length() &gt; 0 ]">
                            <xsl:variable name="aff2">
                                <xsl:apply-templates select="//a1:affiliation[@xml:id=$aff]/a1:address/a1:countryPart"/>
                            </xsl:variable>
                            <xsl:value-of select="normalize-space($aff2)"/>
                            <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:address/a1:postCode[string-length() &gt; 0 ] | //a1:affiliation[@xml:id=$aff]/a1:address/a1:city[string-length() &gt; 0 ]| //a1:affiliation[@xml:id=$aff]/a1:address/a1:state[string-length() &gt; 0 ]| //a1:affiliation[@xml:id=$aff]/a1:address/a1:country[string-length() &gt; 0 ]">
                                <xsl:text>, </xsl:text>
                            </xsl:if>
                        </xsl:if>
                        <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:address/a1:postCode[string-length() &gt; 0 ]">
                            <xsl:variable name="aff2">
                                <xsl:apply-templates select="//a1:affiliation[@xml:id=$aff]/a1:address/a1:postCode"/>
                            </xsl:variable>
                            <xsl:value-of select="normalize-space($aff2)"/>
                            <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:address/a1:city[string-length() &gt; 0 ]| //a1:affiliation[@xml:id=$aff]/a1:address/a1:state[string-length() &gt; 0 ]| //a1:affiliation[@xml:id=$aff]/a1:address/a1:country[string-length() &gt; 0 ]">
                                <xsl:text>, </xsl:text>
                            </xsl:if>
                        </xsl:if>
                        <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:address/a1:city[string-length() &gt; 0 ]">
                            <xsl:variable name="aff2">
                                <xsl:apply-templates select="//a1:affiliation[@xml:id=$aff]/a1:address/a1:city"/>
                            </xsl:variable>
                            <xsl:value-of select="normalize-space($aff2)"/>
                            <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:address/a1:state[string-length() &gt; 0 ]| //a1:affiliation[@xml:id=$aff]/a1:address/a1:country[string-length() &gt; 0 ]">
                                <xsl:text>, </xsl:text>
                            </xsl:if>
                        </xsl:if>
                        <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:address/a1:state[string-length() &gt; 0 ]">
                            <xsl:variable name="aff2">
                                <xsl:apply-templates select="//a1:affiliation[@xml:id=$aff]/a1:address/a1:state"/>
                            </xsl:variable>
                            <xsl:value-of select="normalize-space($aff2)"/>
                            <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:address/a1:country[string-length() &gt; 0 ]">
                                <xsl:text>, </xsl:text>
                            </xsl:if>
                        </xsl:if>
                        <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:address/a1:country[string-length() &gt; 0 ]">
                            <xsl:variable name="aff2">
                                <xsl:apply-templates select="//a1:affiliation[@xml:id=$aff]/a1:address/a1:country"/>
                            </xsl:variable>
                            <xsl:value-of select="normalize-space($aff2)"/>
                        </xsl:if>
                        <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:unparsedAffiliation[string-length() &gt; 0 ]">
                            <xsl:variable name="aff2">
                                <xsl:apply-templates select="//a1:affiliation[@xml:id=$aff]/a1:unparsedAffiliation"/>
                            </xsl:variable>
                            <xsl:value-of select="normalize-space($aff2)"/>
                        </xsl:if>
                    </affiliation>
                </xsl:if>
            </xsl:when>
            <xsl:otherwise>
                <affiliation xmlns="http://www.loc.gov/mods/v3">
                    <xsl:text>Current Address: </xsl:text>
                    <xsl:variable name="translate">
                        <xsl:value-of select="translate($text,'#','')"/>
                    </xsl:variable>
                    <xsl:variable name="aff">
                        <xsl:value-of select="normalize-space(substring-before($translate, $separator))"/>
                    </xsl:variable>
                    <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:orgDiv[string-length() &gt; 0 ]">
                        <xsl:for-each select="//a1:affiliation[@xml:id=$aff]/a1:orgDiv">
                            <xsl:variable name="aff2">
                                <xsl:apply-templates select="."/>
                            </xsl:variable>
                            <xsl:value-of select="normalize-space($aff2)"/>
                            <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:orgName[string-length() &gt; 0 ] | //a1:affiliation[@xml:id=$aff]/a1:address/a1:street[string-length() &gt; 0 ] | //a1:affiliation[@xml:id=$aff]/a1:address/a1:countryPart[string-length() &gt; 0 ]
                                | //a1:affiliation[@xml:id=$aff]/a1:address/a1:postCode[string-length() &gt; 0 ] | //a1:affiliation[@xml:id=$aff]/a1:address/a1:city[string-length() &gt; 0 ]| //a1:affiliation[@xml:id=$aff]/a1:address/a1:state[string-length() &gt; 0 ]| //a1:affiliation[@xml:id=$aff]/a1:address/a1:country[string-length() &gt; 0 ]">
                                <xsl:text>, </xsl:text>
                            </xsl:if>
                        </xsl:for-each>
                    </xsl:if>
                    <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:orgName[string-length() &gt; 0 ]">
                        <xsl:for-each select="//a1:affiliation[@xml:id=$aff]/a1:orgName">
                            <xsl:variable name="aff2">
                                <xsl:apply-templates select="."/>
                            </xsl:variable>
                            <xsl:value-of select="normalize-space($aff2)"/>
                            <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:address/a1:street[string-length() &gt; 0 ] | //a1:affiliation[@xml:id=$aff]/a1:address/a1:countryPart[string-length() &gt; 0 ]
                                | //a1:affiliation[@xml:id=$aff]/a1:address/a1:postCode[string-length() &gt; 0 ] | //a1:affiliation[@xml:id=$aff]/a1:address/a1:city[string-length() &gt; 0 ]| //a1:affiliation[@xml:id=$aff]/a1:address/a1:state[string-length() &gt; 0 ]| //a1:affiliation[@xml:id=$aff]/a1:address/a1:country[string-length() &gt; 0 ]">
                                <xsl:text>, </xsl:text>
                            </xsl:if>
                        </xsl:for-each>
                    </xsl:if>
                    <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:address/a1:street[string-length() &gt; 0 ]">
                        <xsl:variable name="aff2">
                            <xsl:apply-templates select="//a1:affiliation[@xml:id=$aff]/a1:address/a1:street"/>
                        </xsl:variable>
                        <xsl:value-of select="normalize-space($aff2)"/>
                        <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:address/a1:countryPart[string-length() &gt; 0 ]
                            | //a1:affiliation[@xml:id=$aff]/a1:address/a1:postCode[string-length() &gt; 0 ] | //a1:affiliation[@xml:id=$aff]/a1:address/a1:city[string-length() &gt; 0 ]| //a1:affiliation[@xml:id=$aff]/a1:address/a1:state[string-length() &gt; 0 ]| //a1:affiliation[@xml:id=$aff]/a1:address/a1:country[string-length() &gt; 0 ]">
                            <xsl:text>, </xsl:text>
                        </xsl:if>
                    </xsl:if>
                    <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:address/a1:countryPart[string-length() &gt; 0 ]">
                        <xsl:variable name="aff2">
                            <xsl:apply-templates select="//a1:affiliation[@xml:id=$aff]/a1:address/a1:countryPart"/>
                        </xsl:variable>
                        <xsl:value-of select="normalize-space($aff2)"/>
                        <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:address/a1:postCode[string-length() &gt; 0 ] | //a1:affiliation[@xml:id=$aff]/a1:address/a1:city[string-length() &gt; 0 ]| //a1:affiliation[@xml:id=$aff]/a1:address/a1:state[string-length() &gt; 0 ]| //a1:affiliation[@xml:id=$aff]/a1:address/a1:country[string-length() &gt; 0 ]">
                            <xsl:text>, </xsl:text>
                        </xsl:if>
                    </xsl:if>
                    <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:address/a1:postCode[string-length() &gt; 0 ]">
                        <xsl:variable name="aff2">
                            <xsl:apply-templates select="//a1:affiliation[@xml:id=$aff]/a1:address/a1:postCode"/>
                        </xsl:variable>
                        <xsl:value-of select="normalize-space($aff2)"/>
                        <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:address/a1:city[string-length() &gt; 0 ]| //a1:affiliation[@xml:id=$aff]/a1:address/a1:state[string-length() &gt; 0 ]| //a1:affiliation[@xml:id=$aff]/a1:address/a1:country[string-length() &gt; 0 ]">
                            <xsl:text>, </xsl:text>
                        </xsl:if>
                    </xsl:if>
                    <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:address/a1:city[string-length() &gt; 0 ]">
                        <xsl:variable name="aff2">
                            <xsl:apply-templates select="//a1:affiliation[@xml:id=$aff]/a1:address/a1:city"/>
                        </xsl:variable>
                        <xsl:value-of select="normalize-space($aff2)"/>
                        <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:address/a1:state[string-length() &gt; 0 ]| //a1:affiliation[@xml:id=$aff]/a1:address/a1:country[string-length() &gt; 0 ]">
                            <xsl:text>, </xsl:text>
                        </xsl:if>
                    </xsl:if>
                    <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:address/a1:state[string-length() &gt; 0 ]">
                        <xsl:variable name="aff2">
                            <xsl:apply-templates select="//a1:affiliation[@xml:id=$aff]/a1:address/a1:state"/>
                        </xsl:variable>
                        <xsl:value-of select="normalize-space($aff2)"/>
                        <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:address/a1:country[string-length() &gt; 0 ]">
                            <xsl:text>, </xsl:text>
                        </xsl:if>
                    </xsl:if>
                    <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:address/a1:country[string-length() &gt; 0 ]">
                        <xsl:variable name="aff2">
                            <xsl:apply-templates select="//a1:affiliation[@xml:id=$aff]/a1:address/a1:country"/>
                        </xsl:variable>
                        <xsl:value-of select="normalize-space($aff2)"/>
                    </xsl:if>
                    <xsl:if test="//a1:affiliation[@xml:id=$aff]/a1:unparsedAffiliation[string-length() &gt; 0 ]">
                        <xsl:variable name="aff2">
                            <xsl:apply-templates select="//a1:affiliation[@xml:id=$aff]/a1:unparsedAffiliation"/>
                        </xsl:variable>
                        <xsl:value-of select="normalize-space($aff2)"/>
                    </xsl:if>
                </affiliation>
                <xsl:call-template name="tokenizeCur">
                    <xsl:with-param name="text" select="substring-after($text, $separator)"/>
                </xsl:call-template>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    <xsl:template name="affiliation2">
        <xsl:for-each select="//a1:affiliation">
        <affiliation xmlns="http://www.loc.gov/mods/v3">
            <xsl:if test="a1:orgDiv[string-length() &gt; 0 ]">
                <xsl:for-each select="a1:orgDiv">
                    <xsl:variable name="orgDiv">
                        <xsl:apply-templates select="."/>
                    </xsl:variable>
                    <xsl:value-of select="normalize-space($orgDiv)"/>
                    <xsl:if test="a1:orgName[string-length() &gt; 0 ] | a1:address/a1:street[string-length() &gt; 0 ] | a1:address/a1:countryPart[string-length() &gt; 0 ]
                        | a1:address/a1:postCode[string-length() &gt; 0 ] | a1:address/a1:city[string-length() &gt; 0 ]| a1:address/a1:state[string-length() &gt; 0 ]| a1:address/a1:country[string-length() &gt; 0 ]">
                        <xsl:text>, </xsl:text>
                    </xsl:if>
                </xsl:for-each>
            </xsl:if>
            <xsl:if test="a1:orgName[string-length() &gt; 0 ]">
                <xsl:for-each select="a1:orgName">
                    <xsl:variable name="orgName">
                        <xsl:apply-templates select="."/>
                    </xsl:variable>
                    <xsl:value-of select="normalize-space($orgName)"/>
                    <xsl:if test="a1:address/a1:street[string-length() &gt; 0 ] | a1:address/a1:countryPart[string-length() &gt; 0 ]
                        | a1:address/a1:postCode[string-length() &gt; 0 ] | a1:address/a1:city[string-length() &gt; 0 ]| a1:address/a1:state[string-length() &gt; 0 ]| a1:address/a1:country[string-length() &gt; 0 ]">
                        <xsl:text>, </xsl:text>
                    </xsl:if>
                </xsl:for-each>
            </xsl:if>
            <xsl:if test="a1:address/a1:street[string-length() &gt; 0 ]">
                <xsl:variable name="street">
                    <xsl:apply-templates select="a1:address/a1:street"/>
                </xsl:variable>
                <xsl:value-of select="normalize-space($street)"/>
                <xsl:if test="a1:address/a1:countryPart[string-length() &gt; 0 ]
                    | a1:address/a1:postCode[string-length() &gt; 0 ] | a1:address/a1:city[string-length() &gt; 0 ]| a1:address/a1:state[string-length() &gt; 0 ]| a1:address/a1:country[string-length() &gt; 0 ]">
                    <xsl:text>, </xsl:text>
                </xsl:if>
            </xsl:if>
            <xsl:if test="a1:address/a1:postCode[string-length() &gt; 0 ]">
                <xsl:variable name="postCode">
                    <xsl:apply-templates select="a1:address/a1:postCode"/>
                </xsl:variable>
                <xsl:value-of select="normalize-space($postCode)"/>
                <xsl:if test="a1:address/a1:city[string-length() &gt; 0 ]| a1:address/a1:state[string-length() &gt; 0 ]| a1:address/a1:country[string-length() &gt; 0 ]">
                    <xsl:text>, </xsl:text>
                </xsl:if>
            </xsl:if>
            <xsl:if test="a1:address/a1:city[string-length() &gt; 0 ]">
                <xsl:variable name="city">
                    <xsl:apply-templates select="a1:address/a1:city"/>
                </xsl:variable>
                <xsl:value-of select="normalize-space($city)"/>
                <xsl:if test="a1:address/a1:countryPart[string-length() &gt; 0 ]|a1:address/a1:state[string-length() &gt; 0 ]| a1:address/a1:country[string-length() &gt; 0 ]">
                    <xsl:text>, </xsl:text>
                </xsl:if>
            </xsl:if>
            <xsl:if test="a1:address/a1:countryPart[string-length() &gt; 0 ]">
                <xsl:variable name="countryPart">
                    <xsl:apply-templates select="a1:address/a1:countryPart"/>
                </xsl:variable>
                <xsl:value-of select="normalize-space($countryPart)"/>
                <xsl:if test="a1:address/a1:state[string-length() &gt; 0 ]| a1:address/a1:country[string-length() &gt; 0 ]">
                    <xsl:text>, </xsl:text>
                </xsl:if>
            </xsl:if>
            <xsl:if test="a1:address/a1:state[string-length() &gt; 0 ]">
                <xsl:variable name="state">
                    <xsl:apply-templates select="a1:address/a1:state"/>
                </xsl:variable>
                <xsl:value-of select="normalize-space($state)"/>
                <xsl:if test="a1:address/a1:country[string-length() &gt; 0 ]">
                    <xsl:text>, </xsl:text>
                </xsl:if>
            </xsl:if>
            <xsl:if test="a1:address/a1:country[string-length() &gt; 0 ]">
                <xsl:variable name="country">
                    <xsl:apply-templates select="a1:address/a1:country"/>
                </xsl:variable>
                <xsl:value-of select="normalize-space($country)"/>
            </xsl:if>
            <xsl:if test="a1:unparsedAffiliation[string-length() &gt; 0 ]">
                <xsl:variable name="unparsedAffiliation">
                    <xsl:apply-templates select="a1:unparsedAffiliation"/>
                </xsl:variable>
                <xsl:value-of select="normalize-space($unparsedAffiliation)"/>
            </xsl:if>
        </affiliation>
        </xsl:for-each>
    </xsl:template>
    <xsl:template match="@noteRef" name="tokenizeNot">
        <xsl:param name="text" select="@noteRef"/>
        <xsl:param name="separator" select="' '"/>
        <xsl:choose>
            <xsl:when test="not(contains($text, $separator))">
                <xsl:variable name="note">
                    <xsl:value-of select="translate($text,'#','')"/>
                </xsl:variable>
                <xsl:if test="//a1:noteGroup/a1:note[@xml:id=$note]">
                    <description xmlns="http://www.loc.gov/mods/v3">
                        <xsl:if test="//a1:noteGroup/a1:note[@xml:id=$note][string-length() &gt; 0 ]">
                            <xsl:for-each select="//a1:noteGroup/a1:note[@xml:id=$note]">
                                <xsl:variable name="noteRef">
                                    <xsl:apply-templates select="."/>
                                </xsl:variable>
                                <xsl:value-of select="normalize-space($noteRef)"/>
                            </xsl:for-each>
                        </xsl:if>
                    </description>
                </xsl:if>
            </xsl:when>
            <xsl:otherwise>
                <description xmlns="http://www.loc.gov/mods/v3">
                    <xsl:text>Note: </xsl:text>
                    <xsl:variable name="translate">
                        <xsl:value-of select="translate($text,'#','')"/>
                    </xsl:variable>
                    <xsl:variable name="note">
                        <xsl:value-of select="normalize-space(substring-before($translate, $separator))"/>
                    </xsl:variable>
                    <xsl:if test="//a1:noteGroup/a1:note[@xml:id=$note][string-length() &gt; 0 ]">
                        <xsl:for-each select="//a1:noteGroup/a1:note[@xml:id=$note]">
                            <xsl:variable name="noteRef">
                                <xsl:apply-templates select="."/>
                            </xsl:variable>
                            <xsl:value-of select="normalize-space($noteRef)"/>
                        </xsl:for-each>
                    </xsl:if>
                </description>
                <xsl:call-template name="tokenizeNot">
                    <xsl:with-param name="text" select="substring-after($text, $separator)"/>
                </xsl:call-template>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    <xsl:template name="nameAut">
        <name xmlns="http://www.loc.gov/mods/v3">
            <xsl:attribute name="type">personal</xsl:attribute>
            <xsl:if test="a1:honorifics">
                <namePart xmlns="http://www.loc.gov/mods/v3">
                    <xsl:attribute name="type">termsOfAddress</xsl:attribute>
                    <xsl:variable name="honor">
                        <xsl:apply-templates select="a1:honorifics"/>
                    </xsl:variable>
                    <xsl:value-of select="normalize-space($honor)"/>
                </namePart>
            </xsl:if>
            <xsl:if test="a1:givenNames[string-length() &gt; 0]">
                <namePart xmlns="http://www.loc.gov/mods/v3">
                    <xsl:attribute name="type">given</xsl:attribute>
                    <xsl:variable name="given">
                        <xsl:apply-templates select="a1:givenNames"/>
                    </xsl:variable>
                    <xsl:value-of select="normalize-space($given)"/>
                </namePart>
            </xsl:if>
            <xsl:choose>
                <xsl:when test="a1:unparsedName[string-length()&gt;0]">
                    <namePart xmlns="http://www.loc.gov/mods/v3">
                        <xsl:attribute name="type">family</xsl:attribute>
                        <xsl:variable name="unparsedName">
                            <xsl:apply-templates select="a1:unparsedName"/>
                        </xsl:variable>
                        <xsl:value-of select="normalize-space($unparsedName)"/>
                    </namePart>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:if test="a1:familyName[string-length()&gt;0]">
                        <namePart xmlns="http://www.loc.gov/mods/v3">
                            <xsl:attribute name="type">family</xsl:attribute>
                            <xsl:if test="a1:familyNamePrefix">
                                <xsl:variable name="familyNamePrefix">
                                    <xsl:apply-templates select="a1:familyNamePrefix"/>
                                </xsl:variable>
                                <xsl:value-of select="normalize-space($familyNamePrefix)"/>
                                <xsl:text> </xsl:text>
                            </xsl:if>
                            <xsl:variable name="familyName">
                                <xsl:apply-templates select="a1:familyName"/>
                            </xsl:variable>
                            <xsl:value-of select="normalize-space($familyName)"/>
                            <xsl:if test="a1:nameSuffix">
                                <xsl:text> </xsl:text>
                                <xsl:variable name="nameSuffix">
                                    <xsl:apply-templates select="a1:nameSuffix"/>
                                </xsl:variable>
                                <xsl:value-of select="normalize-space($nameSuffix)"/>
                            </xsl:if>
                        </namePart>
                    </xsl:if>
                </xsl:otherwise>
            </xsl:choose>
            <xsl:if test="a1:titlesAfterNames [string-length()&gt;0]">
                <namePart xmlns="http://www.loc.gov/mods/v3">
                    <xsl:attribute name="type">termsOfAddress</xsl:attribute>
                    <xsl:variable name="titlesAfterNames">
                        <xsl:apply-templates select="a1:titlesAfterNames"/>
                    </xsl:variable>
                    <xsl:value-of select="normalize-space($titlesAfterNames)"/>
                </namePart>
            </xsl:if>
            <xsl:if test="a1:degrees[string-length() &gt; 0]">
                <namePart xmlns="http://www.loc.gov/mods/v3">
                    <xsl:attribute name="type">termsOfAddress</xsl:attribute>
                    <xsl:variable name="degrees">
                        <xsl:apply-templates select="a1:degrees"/>
                    </xsl:variable>
                    <xsl:value-of select="normalize-space($degrees)"/>
                </namePart>
            </xsl:if>
            <role xmlns="http://www.loc.gov/mods/v3">
                <roleTerm xmlns="http://www.loc.gov/mods/v3">
                    <xsl:attribute name="type">text</xsl:attribute>
                    <xsl:text>author</xsl:text>
                </roleTerm>
            </role>
        </name>
    </xsl:template>
    <xsl:template name="nameEd">
        <name xmlns="http://www.loc.gov/mods/v3">
            <xsl:attribute name="type">personal</xsl:attribute>
            <xsl:if test="a1:honorifics">
                <namePart xmlns="http://www.loc.gov/mods/v3">
                    <xsl:attribute name="type">termsOfAddress</xsl:attribute>
                    <xsl:variable name="honor">
                        <xsl:apply-templates select="a1:honorifics"/>
                    </xsl:variable>
                    <xsl:value-of select="normalize-space($honor)"/>
                </namePart>
            </xsl:if>
            <xsl:if test="a1:givenNames[string-length() &gt; 0]">
                <namePart xmlns="http://www.loc.gov/mods/v3">
                    <xsl:attribute name="type">given</xsl:attribute>
                    <xsl:variable name="given">
                        <xsl:apply-templates select="a1:givenNames"/>
                    </xsl:variable>
                    <xsl:value-of select="normalize-space($given)"/>
                </namePart>
            </xsl:if>
            <xsl:choose>
                <xsl:when test="a1:unparsedName[string-length()&gt;0]">
                    <namePart xmlns="http://www.loc.gov/mods/v3">
                        <xsl:attribute name="type">family</xsl:attribute>
                        <xsl:variable name="unparsedName">
                            <xsl:apply-templates select="a1:unparsedName"/>
                        </xsl:variable>
                        <xsl:value-of select="normalize-space($unparsedName)"/>
                    </namePart>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:if test="a1:familyName[string-length()&gt;0]">
                        <namePart xmlns="http://www.loc.gov/mods/v3">
                            <xsl:attribute name="type">family</xsl:attribute>
                            <xsl:if test="a1:familyNamePrefix">
                                <xsl:variable name="familyNamePrefix">
                                    <xsl:apply-templates select="a1:familyNamePrefix"/>
                                </xsl:variable>
                                <xsl:value-of select="normalize-space($familyNamePrefix)"/>
                                <xsl:text> </xsl:text>
                            </xsl:if>
                            <xsl:variable name="familyName">
                                <xsl:apply-templates select="a1:familyName"/>
                            </xsl:variable>
                            <xsl:value-of select="normalize-space($familyName)"/>
                            <xsl:if test="a1:nameSuffix">
                                <xsl:text> </xsl:text>
                                <xsl:variable name="nameSuffix">
                                    <xsl:apply-templates select="a1:nameSuffix"/>
                                </xsl:variable>
                                <xsl:value-of select="normalize-space($nameSuffix)"/>
                            </xsl:if>
                        </namePart>
                    </xsl:if>
                </xsl:otherwise>
            </xsl:choose>
            <xsl:if test="a1:titlesAfterNames [string-length()&gt;0]">
                <namePart xmlns="http://www.loc.gov/mods/v3">
                    <xsl:attribute name="type">termsOfAddress</xsl:attribute>
                    <xsl:variable name="titlesAfterNames">
                        <xsl:apply-templates select="a1:titlesAfterNames"/>
                    </xsl:variable>
                    <xsl:value-of select="normalize-space($titlesAfterNames)"/>
                </namePart>
            </xsl:if>
            <xsl:if test="a1:degrees[string-length() &gt; 0]">
                <namePart xmlns="http://www.loc.gov/mods/v3">
                    <xsl:attribute name="type">termsOfAddress</xsl:attribute>
                    <xsl:variable name="degrees">
                        <xsl:apply-templates select="a1:degrees"/>
                    </xsl:variable>
                    <xsl:value-of select="normalize-space($degrees)"/>
                </namePart>
            </xsl:if>
            <role xmlns="http://www.loc.gov/mods/v3">
                <roleTerm xmlns="http://www.loc.gov/mods/v3">
                    <xsl:attribute name="type">text</xsl:attribute>
                    <xsl:text>editor</xsl:text>
                </roleTerm>
            </role>
        </name>
    </xsl:template>
    <xsl:template name="name2">
        <xsl:choose>
            <xsl:when test="a1:personName/a1:honorifics">
                <namePart xmlns="http://www.loc.gov/mods/v3">
                    <xsl:attribute name="type">termsOfAddress</xsl:attribute>
                    <xsl:variable name="honor">
                        <xsl:apply-templates select="a1:personName/a1:honorifics"/>
                    </xsl:variable>
                    <xsl:value-of select="normalize-space($honor)"/>
                </namePart>
            </xsl:when>
            <xsl:when test="a1:personName/a1:givenNames[string-length() &gt; 0]">
                <namePart xmlns="http://www.loc.gov/mods/v3">
                    <xsl:attribute name="type">given</xsl:attribute>
                    <xsl:variable name="given">
                        <xsl:apply-templates select="a1:personName/a1:givenNames"/>
                    </xsl:variable>
                    <xsl:value-of select="normalize-space($given)"/>
                </namePart>
            </xsl:when>
            <xsl:otherwise>
                <namePart xmlns="http://www.loc.gov/mods/v3">
                    <xsl:value-of select="normalize-space(a1:personName)"/>
                </namePart>
            </xsl:otherwise>
        </xsl:choose>
        <xsl:choose>
            <xsl:when test="a1:unparsedName[string-length()&gt;0]">
                <namePart xmlns="http://www.loc.gov/mods/v3">
                    <xsl:attribute name="type">family</xsl:attribute>
                    <xsl:variable name="unparsedName">
                        <xsl:apply-templates select="a1:unparsedName"/>
                    </xsl:variable>
                    <xsl:value-of select="normalize-space($unparsedName)"/>
                </namePart>
            </xsl:when>
            <xsl:otherwise>
                <xsl:if test="a1:personName/a1:familyName[string-length()&gt;0]">
                    <namePart xmlns="http://www.loc.gov/mods/v3">
                        <xsl:attribute name="type">family</xsl:attribute>
                        <xsl:if test="a1:personName/a1:familyNamePrefix">
                            <xsl:variable name="familyNamePrefix">
                                <xsl:apply-templates select="a1:personName/a1:familyNamePrefix"/>
                            </xsl:variable>
                            <xsl:value-of select="normalize-space($familyNamePrefix)"/>
                            <xsl:text> </xsl:text>
                        </xsl:if>
                        <xsl:variable name="familyName">
                            <xsl:apply-templates select="a1:personName/a1:familyName"/>
                        </xsl:variable>
                        <xsl:value-of select="normalize-space($familyName)"/>
                        <xsl:if test="a1:personName/a1:nameSuffix">
                            <xsl:text> </xsl:text>
                            <xsl:variable name="nameSuffix">
                                <xsl:apply-templates select="a1:personName/a1:nameSuffix"/>
                            </xsl:variable>
                            <xsl:value-of select="normalize-space($nameSuffix)"/>
                        </xsl:if>
                    </namePart>
                </xsl:if>
            </xsl:otherwise>
        </xsl:choose>
        <xsl:if test="a1:personName/a1:titlesAfterNames [string-length()&gt;0]">
            <namePart xmlns="http://www.loc.gov/mods/v3">
                <xsl:attribute name="type">termsOfAddress</xsl:attribute>
                <xsl:variable name="titlesAfterNames">
                    <xsl:apply-templates select="a1:personName/a1:titlesAfterNames"/>
                </xsl:variable>
                <xsl:value-of select="normalize-space($titlesAfterNames)"/>
            </namePart>
        </xsl:if>
        <xsl:if test="a1:personName/a1:degrees[string-length() &gt; 0]">
            <namePart xmlns="http://www.loc.gov/mods/v3">
                <xsl:attribute name="type">termsOfAddress</xsl:attribute>
                <xsl:variable name="degrees">
                    <xsl:apply-templates select="a1:personName/a1:degrees"/>
                </xsl:variable>
                <xsl:value-of select="normalize-space($degrees)"/>
            </namePart>
        </xsl:if>
    </xsl:template>
    <xsl:template name="subTitle">
        <xsl:for-each select="//a1:contentMeta/a1:titleGroup/a1:title[@type='subtitle']">
            <subTitle xmlns="http://www.loc.gov/mods/v3">
            <xsl:choose>
            <xsl:when test="@xml:lang">
                <xsl:attribute name="lang">
                    <xsl:value-of select="translate(@xml:lang,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')"/>
                </xsl:attribute>
            </xsl:when>
        </xsl:choose>
        <xsl:if test="not(xml:lang) and //component/@xml:lang[string-length()&gt;0]">
            <xsl:attribute name="lang">
                <xsl:value-of select="translate(//component/@xml:lang,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')"/>
            </xsl:attribute>
        </xsl:if>
            <xsl:variable name="ttl">
                <xsl:apply-templates select="."/>
            </xsl:variable>
            <xsl:value-of select="normalize-space($ttl)"/>
        </subTitle>
        </xsl:for-each>
    </xsl:template>
</xsl:stylesheet>