<?xml version="1.0"?>
<xsl:transform version="1.0" id="ViewNLM-v2-04.xsl" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:util="http://dtd.nlm.nih.gov/xsl/util"
	xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:fn="http://www.w3.org/2005/xpath-functions" 
	exclude-result-prefixes="util xsl xlink mml fn">
	<xsl:output method="html" indent="yes" encoding="UTF-8"/>
        
    
	<xsl:strip-space elements="*"/>
	<xsl:preserve-space elements="preformat"/>
	<xsl:key name="element-by-id" match="*[@id]" use="@id"/>
	<xsl:key name="element-by-rid" match="*[@rid]" use="@rid"/>
	<xsl:variable name="person-strings" select="document('')/*/util:map[@id='person-strings']/item"/>
	<util:map id="person-strings">
		<item source="editor" singular="editor" plural="editors"/>
		<item source="assignee" singular="assignee" plural="assignees"/>
		<item source="translator" singular="translator" plural="translators"/>
		<item source="transed" singular="translator and editor" plural="translators and editors"/>
		<item source="guest-editor" singular="guest editor" plural="guest editors"/>
		<item source="compiler" singular="compiler" plural="compilers"/>
		<item source="inventor" singular="inventor" plural="inventors"/>
	</util:map>
	<xsl:template match="/">
		
        <xsl:apply-templates select="/conference-tracks"/>
        <script type="text/javascript">
			function toggle_visibility(id) {
			   var e = document.getElementById(id);
			   if(e.style.display == 'block')
				  e.style.display = 'none';
			   else
				  e.style.display = 'block';
			}
		</script>
	</xsl:template>

<xsl:template match="/conference-tracks">
	<div class="tg-sectionhead tg-textalignleft" style="background:#f7f7f7;">
        <div class="tg-sectionheading">
        	<span>&#160;</span>
            <h2>Event Tracks</h2>
        </div>
    </div>
    <div>
    	<div style="background:#f7f7f7;">&#160;</div>
        <xsl:for-each select="track">
            <div style="padding:5px; background:#f7f7f7;">
            <div style="background:#ffffff; padding:5px; border-radius:5px; -webkit-border-radius:5px; -moz-border-radius:5px;">
            	<div style="background:#ffffff; padding:10px; border:solid #d90845; border-width:2px; border-radius:5px; -webkit-border-radius:5px; -moz-border-radius:5px;">
                    <h4 style="font-weight:bold; font-size:16px; display:inline;">
                    <a style="cursor:pointer;">
                        <xsl:attribute name="onclick">
                            <xsl:text>toggle_visibility('</xsl:text><xsl:value-of select="track-id"/><xsl:text>');</xsl:text>
                        </xsl:attribute>
                        <xsl:apply-templates select="track-name"/>
                    </a>
                    </h4>
                    <br/>
                    <!--
                    <h4 style="font-weight:bold;"><xsl:apply-templates select="track-name"/></h4>
                    -->
                    <div style="display:none;">
                        <xsl:attribute name="id">
                            <xsl:value-of select="track-id"/>
                        </xsl:attribute>
                            <xsl:apply-templates select="track-description"/>
                    </div>
                </div>
            </div>
            </div>
        </xsl:for-each>
    </div>
</xsl:template>

<xsl:template match="/conference-tracks" mode="old">
	<div class="tg-sectionhead tg-textalignleft">
        <div class="tg-sectionheading">
        	<span>&#160;</span>
            <h2>Event Tracks</h2>
        </div>
    </div>
    <div id="tg-accordion" class="tg-accordion" role="tablist" aria-multiselectable="true">
        <xsl:for-each select="track">
            <div class="tg-panel">
            	<h4 style="font-weight:bold;"><xsl:apply-templates select="track-name"/></h4>
                <div class="tg-panelcontent">
                    <div class="tg-description">
                    	<xsl:apply-templates select="track-description"/>
                    </div>
				</div>
            </div>
        </xsl:for-each>
    </div>
</xsl:template>

<xsl:template match="track-description">
	<xsl:apply-templates/>
</xsl:template>

<xsl:template match="/journal/journal-front/journal-meta/journal-aims-scope" mode="about-the-journal">
	<h3 class="widget-title">Aims and Scope</h3>
    <div style="overflow:hidden; border:thin solid; padding:10px;">
    	<xsl:apply-templates mode="about-the-journal"/>
    </div>
</xsl:template>

<xsl:template match="title" mode="about-the-journal">
	<h4 style="font-size:14px; font-weight:bold; line-height:140%;">
		<xsl:apply-templates mode="about-the-journal"/>
    </h4>
</xsl:template>

<xsl:template match="sec" mode="about-the-journal">
	<div style="overflow:hidden; padding-top:3px; text-align:justify;">
		<xsl:apply-templates mode="about-the-journal"/>
    </div>
</xsl:template>

<xsl:template match="p" mode="about-the-journal">
	<p style="line-height:140%; max-height:none; margin:0px; padding:0px; ">
		<xsl:apply-templates mode="about-the-journal"/>
	</p>
    <br />
</xsl:template>

<xsl:template match="italic" mode="about-the-journal">
	<em>
		<xsl:apply-templates mode="about-the-journal"/>
    </em>
</xsl:template>

<xsl:template match="bold" mode="about-the-journal">
	<strong>
    	<xsl:apply-templates mode="about-the-journal"/>
	</strong>
</xsl:template>

<xsl:template match="underline" mode="about-the-journal">
	<span style="text-decoration:underline;">
		<xsl:apply-templates mode="about-the-journal"/>
    </span>
</xsl:template>

<xsl:template match="sup" mode="about-the-journal">
	<sup>
		<xsl:apply-templates mode="about-the-journal"/>
    </sup>
</xsl:template>

<xsl:template match="sub" mode="about-the-journal">
	<sub>
    	<xsl:apply-templates mode="about-the-journal"/>
	</sub>
</xsl:template>

<xsl:template match="/endorsement/endorsement-body/endorsement-list">
    <xsl:for-each select="display-quote">
		<div style="	border: thin solid; border-color: #eeeeee; -webkit-border-radius: 10px; -moz-border-radius: 10px; border-radius: 10px; padding:5px; 
    				background: #ffffff; /* Old browsers */
                    background: -moz-linear-gradient(top,  #ffffff 0%, #f6f6f6 47%, #ededed 100%); /* FF3.6+ */
                    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ffffff), color-stop(47%,#f6f6f6), color-stop(100%,#ededed)); /* Chrome,Safari4+ */
                    background: -webkit-linear-gradient(top,  #ffffff 0%,#f6f6f6 47%,#ededed 100%); /* Chrome10+,Safari5.1+ */
                    background: -o-linear-gradient(top,  #ffffff 0%,#f6f6f6 47%,#ededed 100%); /* Opera 11.10+ */
                    background: -ms-linear-gradient(top,  #ffffff 0%,#f6f6f6 47%,#ededed 100%); /* IE10+ */
                    background: linear-gradient(to bottom,  #ffffff 0%,#f6f6f6 47%,#ededed 100%); /* W3C */
                    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#ededed',GradientType=0 ); /* IE6-9 */

    ">
            <xsl:apply-templates select="comment" mode="endr"/>
            <br />
            <strong><xsl:apply-templates select="attrib" mode="endr"/></strong>
            <br />
            <xsl:apply-templates select="aff" mode="endr"/>
        </div>
        <hr />
    </xsl:for-each>
</xsl:template>

<xsl:template match="comment" mode="endr">
	<div style="text-align:justify; font-style:italic;">
		<xsl:apply-templates />
	</div>
	
</xsl:template>

<xsl:template match="attrib" mode="endr">
    <xsl:apply-templates />
</xsl:template>

<xsl:template match="aff" mode="endr">
    <xsl:apply-templates />
</xsl:template>

<xsl:template match="/journal/journal-front/journal-meta/journal-society-accreditation">
	<div style="overflow:hidden; width: 210px; padding:10px;
    background: rgb(245,246,246); /* Old browsers */
background: -moz-linear-gradient(top,  rgba(245,246,246,1) 0%, rgba(219,220,226,1) 21%, rgba(184,186,198,1) 49%, rgba(221,223,227,1) 80%, rgba(245,246,246,1) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(245,246,246,1)), color-stop(21%,rgba(219,220,226,1)), color-stop(49%,rgba(184,186,198,1)), color-stop(80%,rgba(221,223,227,1)), color-stop(100%,rgba(245,246,246,1))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top,  rgba(245,246,246,1) 0%,rgba(219,220,226,1) 21%,rgba(184,186,198,1) 49%,rgba(221,223,227,1) 80%,rgba(245,246,246,1) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top,  rgba(245,246,246,1) 0%,rgba(219,220,226,1) 21%,rgba(184,186,198,1) 49%,rgba(221,223,227,1) 80%,rgba(245,246,246,1) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top,  rgba(245,246,246,1) 0%,rgba(219,220,226,1) 21%,rgba(184,186,198,1) 49%,rgba(221,223,227,1) 80%,rgba(245,246,246,1) 100%); /* IE10+ */
background: linear-gradient(to bottom,  rgba(245,246,246,1) 0%,rgba(219,220,226,1) 21%,rgba(184,186,198,1) 49%,rgba(221,223,227,1) 80%,rgba(245,246,246,1) 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f5f6f6', endColorstr='#f5f6f6',GradientType=0 ); /* IE6-9 */

    ">
        <div style="overflow:hidden; padding:5px; background-color:#FFF;">
        <strong>Society Affiliation</strong>
        <hr />
            <xsl:for-each select="society-entry">
                <a target="_blank">
                    <xsl:attribute name="href"><xsl:value-of select="society-link" disable-output-escaping="yes"/></xsl:attribute>
                    <img>
                        <xsl:attribute name="src">
                            <xsl:text>../../../../../../../journal-images/society-logo/</xsl:text><xsl:value-of select="society-logo"/>
                        </xsl:attribute>
                    </img>
                </a>
                <hr/>
            </xsl:for-each>
        </div>
    </div>
</xsl:template>

    
<xsl:template match="/content/content-body/volume-list" mode="volume-xml-browser">
<xsl:param name="jour1"/>
	<h4 style="display:inline;">Browse Contents</h4>
    <br />
	<div style="padding:10px; overflow:hidden; width:190px;">
    <xsl:for-each select="volume-entry">
    	
        <xsl:variable name="volumeentry">
        	<xsl:text>../contents/volume-xml/</xsl:text><xsl:value-of select="."/><xsl:text>.xml</xsl:text>
        </xsl:variable>
        <div style="border-bottom:thin solid #ffffff; ">
        <xsl:apply-templates select="document($volumeentry)/volume" mode="volume-xml-browser">
        	<xsl:with-param name="jour2" select="$jour1"/>
        	<xsl:with-param name="volentry" select="$volumeentry"/>
        </xsl:apply-templates>
        </div>
    </xsl:for-each>
	</div>
</xsl:template>

<xsl:template match="/volume" mode="volume-xml-browser">
	<xsl:param name="jour2"/>
	<xsl:param name="volentry"/>
		<a class="white" target="_blank">
        <xsl:attribute name="href">
        	<xsl:text>../../../../../</xsl:text><xsl:value-of select="$journal"/><xsl:text>/VOLUME/</xsl:text><xsl:value-of select="volume-front/volume-meta/volume-ref-code"/><xsl:text>/</xsl:text>
        </xsl:attribute>
        <h5 style="display:inline;"><xsl:value-of select="volume-front/volume-meta/volume-title"/><xsl:text> - </xsl:text><xsl:value-of select="volume-front/volume-meta/volume-year"/></h5>
        </a>
        <br />
</xsl:template>
    
<xsl:template match="/banner-menu/menu-list" mode="banner-menu">
    <ul id="BannerButtons" style="float:left;">
        <xsl:for-each select="menu-item">
            <li>
                <a target="_parent">
                    <xsl:attribute name="href">
                        <xsl:value-of select="menu-link" disable-output-escaping="yes"/>
                    </xsl:attribute>
                    <xsl:attribute name="style">
                        <xsl:value-of select="menu-style" disable-output-escaping="yes"/>
                    </xsl:attribute>
                    <xsl:value-of select="menu-title-line-one" disable-output-escaping="yes"/> 
                    <br />
                    <xsl:value-of select="menu-title-line-two" disable-output-escaping="yes"/> 
                </a>
            </li>
        </xsl:for-each>
    </ul>
</xsl:template>
    
    <xsl:template match="/menu/menu-list" mode="additional">
	<xsl:if test="@menu-list-type='additional'">
        <ul id="MenuButtons">
            <xsl:for-each select="menu-item">
                <li style="list-style:none;">
                    <a target="_parent">
                        <xsl:attribute name="href">
                            <xsl:value-of select="menu-link" disable-output-escaping="yes"/>
                        </xsl:attribute>
                        <xsl:value-of select="menu-title" disable-output-escaping="yes"/>
                    </a>
                </li>
            </xsl:for-each>
        </ul>
    </xsl:if>
</xsl:template>

<xsl:template match="/menu/menu-list" mode="standard">
	<xsl:if test="@menu-list-type='standard'">
        <ul id="MenuButtonsRev">
            <xsl:for-each select="menu-item">
                <li style="list-style:none;">
                    <a target="_parent">
                        <xsl:attribute name="href">
                            <xsl:value-of select="menu-link" disable-output-escaping="yes"/>
                        </xsl:attribute>
                        <xsl:value-of select="menu-title" disable-output-escaping="yes"/>
                    </a>
                </li>
            </xsl:for-each>
        </ul>
    </xsl:if>
</xsl:template>

<xsl:template match="/journal/journal-front/journal-meta/social-media-link-list" mode="social-media">
    <xsl:if test="social-media-link">
        <xsl:apply-templates select="social-media-link" mode="facebook"/>
        <xsl:text> </xsl:text>
        <xsl:apply-templates select="social-media-link" mode="twitter"/>
        <xsl:text> </xsl:text>
        <xsl:apply-templates select="social-media-link" mode="linkedin"/>
        <xsl:text> </xsl:text>
        <xsl:apply-templates select="social-media-link" mode="wordpress"/>
        <xsl:text> </xsl:text>
        <xsl:apply-templates select="social-media-link" mode="pinterest"/>
        <xsl:text> </xsl:text>
        <xsl:apply-templates select="social-media-link" mode="youtube"/>
    </xsl:if>
</xsl:template>

<xsl:template match="social-media-link" mode="facebook">
    <xsl:if test="@social-media-link-type='facebook'">
        <a target="_blank">
            <xsl:attribute name="href">
                <xsl:value-of select="." disable-output-escaping="yes"/>
            </xsl:attribute>
            <img>
                <xsl:attribute name="src">
                    <xsl:text>../../images/facebook.png</xsl:text>
                </xsl:attribute>
            </img>
        </a>
    </xsl:if>
</xsl:template>

<xsl:template match="social-media-link" mode="twitter">
    <xsl:if test="@social-media-link-type='twitter'">
        <a target="_blank">
            <xsl:attribute name="href">
                <xsl:value-of select="." disable-output-escaping="yes"/>
            </xsl:attribute>
            <img>
                <xsl:attribute name="src">
                    <xsl:text>../../images/twitter.png</xsl:text>
                </xsl:attribute>
            </img>
        </a>
    </xsl:if>
</xsl:template>

<xsl:template match="social-media-link" mode="linkedin">
    <xsl:if test="@social-media-link-type='linkedin'">
        <a target="_blank">
            <xsl:attribute name="href">
                <xsl:value-of select="." disable-output-escaping="yes"/>
            </xsl:attribute>
            <img>
                <xsl:attribute name="src">
                    <xsl:text>../../images/linkedin.png</xsl:text>
                </xsl:attribute>
            </img>
        </a>
    </xsl:if>
</xsl:template>

<xsl:template match="social-media-link" mode="wordpress">
    <xsl:if test="@social-media-link-type='wordpress'">
        <a target="_blank">
            <xsl:attribute name="href">
                <xsl:value-of select="." disable-output-escaping="yes"/>
            </xsl:attribute>
            <img>
                <xsl:attribute name="src">
                    <xsl:text>../../images/wordpress.png</xsl:text>
                </xsl:attribute>
            </img>
        </a>
    </xsl:if>
</xsl:template>

<xsl:template match="social-media-link" mode="pinterest">
    <xsl:if test="@social-media-link-type='pinterest'">
        <a target="_blank">
            <xsl:attribute name="href">
                <xsl:value-of select="." disable-output-escaping="yes"/>
            </xsl:attribute>
            <img>
                <xsl:attribute name="src">
                    <xsl:text>../../images/pinterest.png</xsl:text>
                </xsl:attribute>
            </img>
        </a>
    </xsl:if>
</xsl:template>

<xsl:template match="social-media-link" mode="youtube">
    <xsl:if test="@social-media-link-type='youtube'">
        <a target="_blank">
            <xsl:attribute name="href">
                <xsl:value-of select="." disable-output-escaping="yes"/>
            </xsl:attribute>
            <img>
                <xsl:attribute name="src">
                    <xsl:text>../../images/youtube.png</xsl:text>
                </xsl:attribute>
            </img>
        </a>
    </xsl:if>
</xsl:template>

<xsl:template match="/menu/menu-list" mode="main-menu">
    <xsl:if test="@menu-list-type='main'">
        <div align="center">
            <ul class="menuTemplate2 decor2_1" license="mylicense">
                <xsl:for-each select="menu-item">
                <li>
                    <a href="#CSS-Menu">
                        <xsl:attribute name="href">
                            <xsl:value-of select="menu-link" disable-output-escaping="yes"/>
                        </xsl:attribute>
                        <xsl:if test="menu-container">
                            <xsl:attribute name="class">
                                <xsl:text>arrow</xsl:text>
                            </xsl:attribute>
                        </xsl:if>
                        <xsl:value-of select="menu-title" disable-output-escaping="yes"/>
                    </a>
                    <xsl:for-each select="menu-container">
                        <div class="drop decor2_2">
                            <xsl:attribute name="style">
                                <xsl:text>width: </xsl:text><xsl:value-of select="menu-container-width"/><xsl:text>px;</xsl:text>
                            </xsl:attribute>
                            <xsl:for-each select="sub-menu-header">
                                <div>
                                    <xsl:if test="@sub-menu-header-type='horizontal'">
                                        <xsl:attribute name="class">
                                            <xsl:text>left</xsl:text>
                                        </xsl:attribute>
                                    </xsl:if>
                                    <xsl:for-each select="sub-menu-segment">
                                        <b><xsl:value-of select="sub-menu-segment-title"/></b>
                                        <div>
                                            <xsl:for-each select="sub-menu-item">
                                                <a>
                                                    <xsl:attribute name="href">
                                                        <xsl:value-of select="menu-link" disable-output-escaping="yes"/>
                                                    </xsl:attribute>
                                                    <xsl:value-of select="menu-title" disable-output-escaping="yes"/>
                                                </a>
                                                <br />
                                            </xsl:for-each>
                                        </div>
                                    </xsl:for-each>
                                </div>
                            </xsl:for-each>
                        </div>
                    </xsl:for-each>
                </li>
                <li class="separator">
                </li>
                </xsl:for-each>
            </ul>
        </div>
    </xsl:if>
</xsl:template>
    
    
	<xsl:template match="article">
		<xsl:call-template name="make-a-piece"/>
	</xsl:template>
	<xsl:template name="make-a-piece">
		<xsl:variable name="which-piece">
			<xsl:value-of select="concat(local-name(), '-level-', count(ancestor::*))"/>
		</xsl:variable>
		<xsl:call-template name="nl-2"/>
		<div id="{$which-piece}-front" class="fm">
			<xsl:call-template name="nl-1"/>
			<xsl:call-template name="make-front"/>
			<xsl:call-template name="nl-1"/>
		</div>
		<xsl:if test="not(/article/@status='permanent-retracted') and not(/article/@status='temporary-retracted')">
		<xsl:call-template name="nl-2"/>
		<div id="{$which-piece}-body" class="body">
			<xsl:call-template name="nl-1"/>
			<xsl:call-template name="make-body"/>
			<xsl:call-template name="nl-1"/>
		</div>
		<xsl:call-template name="nl-2"/>
		<div id="{$which-piece}-back" class="bm">
			<xsl:call-template name="nl-1"/>
			<xsl:call-template name="make-back"/>
			<xsl:call-template name="nl-1"/>
		</div>
		<xsl:call-template name="nl-2"/>
		<div id="{$which-piece}-end-metadata" class="fm">
			<xsl:call-template name="nl-1"/>
			<xsl:call-template name="make-end-metadata"/>
			<xsl:call-template name="nl-1"/>
		</div>
		</xsl:if>
	</xsl:template>
	<xsl:template name="capitalize">
		<xsl:param name="str"/>
		<xsl:value-of
			select="translate($str,
                          'abcdefghjiklmnopqrstuvwxyz',
                          'ABCDEFGHJIKLMNOPQRSTUVWXYZ')"
		/>
	</xsl:template>
	<xsl:template name="language">
		<xsl:param name="lang"/>
		<xsl:choose>
			<xsl:when test="$lang='fr' or $lang='FR'"> (Fre).</xsl:when>
			<xsl:when test="$lang='jp' or $lang='JP'"> (Jpn).</xsl:when>
			<xsl:when test="$lang='ru' or $lang='RU'"> (Rus).</xsl:when>
			<xsl:when test="$lang='de' or $lang='DE'"> (Ger).</xsl:when>
			<xsl:when test="$lang='se' or $lang='SE'"> (Swe).</xsl:when>
			<xsl:when test="$lang='it' or $lang='IT'"> (Ita).</xsl:when>
			<xsl:when test="$lang='he' or $lang='HE'"> (Heb).</xsl:when>
			<xsl:when test="$lang='sp' or $lang='SP'"> (Spa).</xsl:when>
		</xsl:choose>
	</xsl:template>
	<xsl:template name="cleantitle">
		<xsl:param name="str"/>
		<xsl:value-of select="translate($str,'. ,-_','')"/>
	</xsl:template>
	<xsl:template name="nl-1">
		<xsl:text>&#xA;</xsl:text>
	</xsl:template>
	<xsl:template name="nl-2">
		<xsl:text>&#xA;</xsl:text>
		<xsl:text>&#xA;</xsl:text>
	</xsl:template>
	<xsl:template name="make-id">
		<xsl:if test="@id">
        <a>
			<xsl:attribute name="name">
				<xsl:value-of select="@id"/>
			</xsl:attribute>
        </a>
		</xsl:if>
	</xsl:template>
	<xsl:template name="make-src">
		<xsl:if test="@xlink:href">
			<xsl:attribute name="src">
				<xsl:text>../../../../../../../contents/figures/</xsl:text><xsl:value-of select="$journal"/><xsl:text>/</xsl:text><xsl:value-of select="@xlink:href"/>
			</xsl:attribute>
		</xsl:if>
	</xsl:template>
	<xsl:template name="make-href">
		<xsl:if test="@xlink:href">
			<xsl:attribute name="href">
				<xsl:value-of select="@xlink:href"/>
			</xsl:attribute>
		</xsl:if>
	</xsl:template>
	<xsl:template name="make-email">
		<xsl:if test="@xlink:href">
			<xsl:attribute name="href">
				<xsl:value-of select="concat('mailto:', @xlink:href)"/>
			</xsl:attribute>
		</xsl:if>
	</xsl:template>
	<xsl:template name="make-anchor">
		<xsl:if test="@id">
			<a name="{@id}"/>
		</xsl:if>
	</xsl:template>
	<xsl:template name="display-id">
	</xsl:template>
	<xsl:template name="table-setup-l-wide">
		<xsl:call-template name="nl-1"/>
		<tr>
			<td  class="td-wide"/>
			<td/>
		</tr>
		<xsl:call-template name="nl-1"/>
	</xsl:template>

	<xsl:template name="table-setup-l-narrow">
		<xsl:call-template name="nl-1"/>
		<tr>
			<td class="td-narrow"/>
			<td/>
		</tr>
		<xsl:call-template name="nl-1"/>
	</xsl:template>

	<xsl:template name="table-setup-even">
		<xsl:call-template name="nl-1"/>
		<tr>
			<td class="td-even"/>
			<td/>
		</tr>
		<xsl:call-template name="nl-1"/>
	</xsl:template>


	<!-- ============================================================= -->
	<!-- "make-figs-and-tables"                                        -->
	<!-- ============================================================= -->

	<!-- initial context node is article -->

	<xsl:template name="make-figs-and-tables">

		<xsl:if test="body//fig[not(parent::fig-group)] | back//fig[not(parent::fig-group)]">
			
			<xsl:call-template name="nl-1"/>

			<h2><span class="tl-main-part">FIGURES</span></h2>
			<xsl:call-template name="nl-1"/>

			<table width="100%" class="bm">
				<xsl:call-template name="table-setup-l-wide"/>

				<!-- each figure is a row -->
				<xsl:apply-templates select="body//fig | back//fig" mode="put-at-end"/>
			</table>

		</xsl:if>

		<xsl:if test="body//table-wrap | back//table-wrap">
			
			<xsl:call-template name="nl-1"/>

			<h2><span class="tl-main-part">TABLES</span></h2>
			<xsl:call-template name="nl-1"/>

			<xsl:apply-templates select="body//table-wrap | back//table-wrap" mode="put-at-end"/>
			<xsl:call-template name="nl-1"/>
		</xsl:if>

	</xsl:template>



	<!-- ============================================================= -->
	<!-- 6. SUPPRESSED ELEMENTS                                        -->
	<!-- ============================================================= -->

	<!-- suppressed in no-mode (processed in mode "front") -->

	<xsl:template match="journal-meta | article-meta"/>


	<!-- not handled by this transform -->

	<xsl:template match="sub-article | response"/>


	<!-- xlink attributes are generally suppressed; note however that
     @xlink:href is used in some element templates. -->

	<xsl:template match="@xlink:*"/>


	<!-- Tables and figures are displayed at the end of the document,
     using mode "put-at-end".
     So, in no-mode, we suppress them: -->

	<xsl:template match="fig | fig-group | table-wrap | table-wrap-group"/>



	<!-- ============================================================= -->
	<!-- CALLED TEMPLATES FOR ARTICLE PARTS                            -->
	<!-- ============================================================= -->

	<!-- ============================================================= -->
	<!--  7. MAKE-HTML-HEADER                                          -->
	<!-- ============================================================= -->

	<xsl:template name="make-html-header"><head>
			<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
			<meta http-equiv="X-UA-Compatible" content="IE=9" />
			<meta http-equiv="X-UA-Compatible" content="IE=edge" />
			
			<meta name="MS.LOCALE" content="en-us" />
			<link href="../../../scripts/bentham.css" rel="stylesheet" type="text/css" />
			<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
			<script src="../../../scripts/jquery-1.2.2.pack.js" type="text/javascript"></script>
            <link href="../../../scripts/facebox.css" media="screen" rel="stylesheet" type="text/css" />
            <script src="../../../scripts/facebox.js" type="text/javascript"></script>
            <script language="Javascript" type="text/javascript" src="../../../../mathml/mathml_viewer.js"></script>
            <script type="text/javascript">
                jQuery(document).ready(function($) {
                  $('a[rel*=facebox]').facebox() 
                })
            </script>
			<xsl:call-template name="nl-1"/>
			
			
			
			<title>
                    <xsl:value-of select="/article/front/article-meta/title-group/article-title"/><xsl:text> ~ Fulltext</xsl:text>
            </title>
			<meta name="dc.identifier">
				<xsl:attribute name="content">
					<xsl:text>doi:</xsl:text><xsl:value-of select="/article/front/article-meta/article-id[2]"/>
				</xsl:attribute>
			</meta>
<meta name="keywords">
<xsl:attribute name="content"><xsl:value-of select="/article/front/article-meta/title-group/article-title"/>, 
<xsl:for-each select="/article/front/article-meta/kwd-group/kwd">
<xsl:value-of select="."/><xsl:text>, </xsl:text>
</xsl:for-each>
<xsl:for-each select="/article/front/article-meta/contrib-group/contrib"><xsl:value-of select="name/given-names"/><xsl:text> </xsl:text><xsl:value-of select="name/surname"/>                   
<xsl:choose>
                        <xsl:when test="following-sibling::contrib">
                            <xsl:text>, </xsl:text>
                        </xsl:when><xsl:otherwise><xsl:text></xsl:text>
                        </xsl:otherwise>
                    </xsl:choose>
				</xsl:for-each>, <xsl:value-of select="/article/front/article-meta/article-id"/>
</xsl:attribute> 
</meta>          
                       


		

		<meta name="description">
<xsl:attribute name="content"><xsl:value-of select="/article/front/article-meta/title-group/article-title"/></xsl:attribute> 
</meta>


<meta name="citation_title">
<xsl:attribute name="content"><xsl:value-of select="/article/front/article-meta/title-group/article-title"/></xsl:attribute> 
</meta>


<xsl:for-each select="/article/front/article-meta/contrib-group/contrib">
<meta name="citation_author">
<xsl:attribute name="content"><xsl:value-of select="name/surname"/>, <xsl:value-of select="name/given-names"/></xsl:attribute>
</meta>
</xsl:for-each>

<meta name="citation_date">
<xsl:attribute name="content"><xsl:value-of select="/article/front/article-meta/pub-date/year"/>/<xsl:value-of select="/article/front/article-meta/pub-date/month"/>/<xsl:value-of select="/article/front/article-meta/pub-date/day"/></xsl:attribute> 
</meta>

<meta name="citation_journal_title">
<xsl:attribute name="content"><xsl:value-of select="/article/front/journal-meta/journal-title"/></xsl:attribute> 
</meta>


<meta name="citation_volume">
<xsl:attribute name="content"><xsl:value-of select="/article/front/article-meta/volume"/></xsl:attribute> 
</meta>

<meta name="citation_issue">
<xsl:attribute name="content">
<xsl:choose>
<xsl:when test="/article/front/article-meta/issue!=null">
<xsl:value-of select="/article/front/article-meta/issue"/>
</xsl:when>
<xsl:otherwise><xsl:text>1</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute> 
</meta>


<meta name="citation_pdf_url">
<xsl:attribute name="content">http://benthamopen.com/contents/pdf/<xsl:value-of select="/article/front/article-meta/article-id" mode="publisher-id"/>.pdf</xsl:attribute> 
</meta>
			
			
			<xsl:call-template name="nl-1"/>

			<xsl:call-template name="nl-1"/>
			
			
			<script>
				$(function() {
				    var moveLeft = 0;
				    var moveDown = 0;
				    $('a.popper').hover(function(e) {
				
				        var target = '#' + ($(this).attr('data-popbox'));
				
				        $(target).show();
				        moveLeft = $(this).outerWidth();
				        moveDown = ($(target).outerHeight() / 2);
				    }, function() {
				        var target = '#' + ($(this).attr('data-popbox'));
				        $(target).hide();
				    });
				
				    $('a.popper').hover(function (e) {    
					    var target = '#' + ($(this).attr('data-popbox'));
					    $(target).show();
					    moveLeft = $(this).outerWidth();
					    moveDown = ($(target).outerHeight() / 2);
					}, function () {
					    var target = '#' + ($(this).attr('data-popbox'));
					    if (!($("a.popper").hasClass("show"))) {
					        $(target).hide(); //dont hide popup if it is clicked
					    }
					});
					$('a.popper').click(function (e) {
					    var target = '#' + ($(this).attr('data-popbox'));
					    if (!($(this).hasClass("show"))) {
					        $(target).show();
					    }
					    $(this).toggleClass("show");
					});				
				});
				</script>
			
		</head>

	</xsl:template>


	<!-- ============================================================= -->
	<!--  8. MAKE-FRONT                                                -->
	<!-- ============================================================= -->

	<!-- initial context node is /article -->

	<xsl:template name="make-front">
		<xsl:variable name="volpath">
			<xsl:text>../contents/volume-xml/</xsl:text><xsl:value-of select="$volume"/><xsl:text>.xml</xsl:text>
		</xsl:variable>
	    <xsl:call-template name="nl-1"/>
		<xsl:call-template name="nl-1"/>
		<xsl:choose>


    <xsl:when test="/article/@status='permanent-retracted'">
		<div style="overflow:hidden;  padding:5px;">        
	  <div style="overflow:hidden;  padding:5px;">
	  
	  <h1 class="orange_gold">Retracted</h1>
	  <div class="silver" style="overflow:hidden;  padding:5px; font-size:16px; text-align:justify;">
	  <xsl:text>The article entitled "</xsl:text><strong><xsl:apply-templates select="front/article-meta/title-group" mode="front"/></strong><xsl:text>" authored by </xsl:text>
	  <em>
	  <strong>
	  <xsl:for-each select="front/article-meta/contrib-group/contrib">
						<xsl:choose>
							<xsl:when test="@xlink:href">
								<a>
								<xsl:call-template name="make-href"/>
								<xsl:call-template name="make-id"/>
								<xsl:apply-templates select="name | collab" mode="front"/>
								</a>
							</xsl:when>
							<xsl:otherwise>
								<span class="capture-id">
								<xsl:call-template name="make-id"/>
								<strong><xsl:apply-templates select="name | collab" mode="front"/></strong>
								</span>
							</xsl:otherwise>
						</xsl:choose>
						<xsl:apply-templates
						select="*[not(self::name) and not(self::collab) and not(self::xref) and not(self::degrees)]" mode="front"/>
						<xsl:choose>
							<xsl:when test="following-sibling::contrib">
								<span><strong><xsl:text>, </xsl:text></strong></span>
							</xsl:when>
							<xsl:otherwise>
								<xsl:text></xsl:text>
							</xsl:otherwise>
						</xsl:choose>
					</xsl:for-each>
	  </strong>
	  </em>
	  <xsl:text> is retracted. The author(s) are requested to kindly contact </xsl:text><a href="mailto:info@benthamOpen.com">info@benthamOpen.com</a><xsl:text> as soon as possible.</xsl:text>
	  </div>
	  	    </div>
	    </div>
	</xsl:when>
    
    <xsl:when test="/article/@status='temporary-retracted'">
		<div style="overflow:hidden;  padding:5px;">        
	  <div style="overflow:hidden;  padding:5px;">
	  
	  <h1 class="orange_gold">Temporarily Removed</h1>
	  <div class="silver" style="overflow:hidden;  padding:5px; font-size:16px; text-align:justify;">
	  <xsl:text>The article entitled "</xsl:text><strong><xsl:apply-templates select="front/article-meta/title-group" mode="front"/></strong><xsl:text>" authored by </xsl:text>
	  <em>
	  <strong>
	  <xsl:for-each select="front/article-meta/contrib-group/contrib">
						<xsl:choose>
							<xsl:when test="@xlink:href">
								<a>
								<xsl:call-template name="make-href"/>
								<xsl:call-template name="make-id"/>
								<xsl:apply-templates select="name | collab" mode="front"/>
								</a>
							</xsl:when>
							<xsl:otherwise>
								<span class="capture-id">
								<xsl:call-template name="make-id"/>
								<strong><xsl:apply-templates select="name | collab" mode="front"/></strong>
								</span>
							</xsl:otherwise>
						</xsl:choose>
						<xsl:apply-templates
						select="*[not(self::name) and not(self::collab) and not(self::xref) and not(self::degrees)]" mode="front"/>
						<xsl:choose>
							<xsl:when test="following-sibling::contrib">
								<span><strong><xsl:text>, </xsl:text></strong></span>
							</xsl:when>
							<xsl:otherwise>
								<xsl:text></xsl:text>
							</xsl:otherwise>
						</xsl:choose>
					</xsl:for-each>
	  </strong>
	  </em>
	  <xsl:text> is temporarily removed. The author(s) are requested to kindly contact </xsl:text><a href="mailto:info@benthamOpen.com">info@benthamOpen.com</a><xsl:text> as soon as possible.</xsl:text>
	  </div>
	  	    </div>
	    </div>
	</xsl:when>
	<xsl:otherwise>
				<xsl:for-each select="front/article-meta">
   				<h1 class="orange_gold"><xsl:apply-templates select="title-group" mode="front"/></h1>
                <br />
                <br />

					<xsl:for-each select="contrib-group/contrib">
						<xsl:choose>
							<xsl:when test="@xlink:href">
								<a>
								<xsl:call-template name="make-href"/>
								<xsl:call-template name="make-id"/>
								<xsl:apply-templates select="name | collab" mode="front"/>
								</a>
							</xsl:when>
							<xsl:otherwise>
								<span class="capture-id">
								<xsl:call-template name="make-id"/>
								<strong><xsl:apply-templates select="name | collab" mode="front"/></strong>
								</span>
							</xsl:otherwise>
						</xsl:choose>
						<xsl:apply-templates
						select="*[not(self::name) and not(self::collab) and not(self::xref) and not(self::degrees)]" mode="front"/>
						<xsl:choose>
							<xsl:when test="following-sibling::contrib">
								<span><strong><xsl:text>, </xsl:text></strong></span>
							</xsl:when>
							<xsl:otherwise>
								<xsl:text></xsl:text>
							</xsl:otherwise>
						</xsl:choose>
					</xsl:for-each>
					<br />
					
                    <xsl:for-each select="aff | contrib-group/aff">
						<div><xsl:apply-templates select="self::aff" mode="aff-outside-contrib"/></div>
					</xsl:for-each>
                    <br />


					
                    
 			</xsl:for-each>

				
			
<xsl:for-each select="front/article-meta">
	<xsl:if test="abstract | trans-abstract">
    <div align="center">
        <div class="abstract">	
            <xsl:for-each select="abstract | trans-abstract">
                <xsl:call-template name="words-for-abstract-title"/>
                <xsl:apply-templates select="*[not(self::title)]"/>
            </xsl:for-each>
        </div>
        <div class="keywords">	
            <xsl:if test="kwd-group">
                <xsl:apply-templates select="kwd-group"/>
            </xsl:if>
        </div>
        <br />
    </div>
	</xsl:if>
    <hr/>
    <div style="overflow:hidden;">
    <h3 style="display:inline;"><xsl:text>Article Information</xsl:text></h3>
    <br />
    <xsl:if test="/article/@crossmark-status='yes'">
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js" ></script>
	<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.7/jquery-ui.min.js" ></script>
	<script type="text/javascript" src="https://crossmark.crossref.org/javascripts/v1.5/crossmark.min.js"></script>
	<a id="open-crossmark" href="#" style="padding: 3px 0 13px 0;"><img style="border: 0; display: none;" id="crossmark-icon" src="https://crossmark.crossref.org/images/crossmark_button.png" /></a>
	<div id="crossmark-dialog" style="display: none;" title="">
	<!-- the external CrossMark data is loaded inside this iframe -->
	<iframe id="crossmark-dialog-frame" frameborder="0"></iframe>
	</div>
	</xsl:if>
    <div style="float:left; overflow:hidden; width:350px;">
    
        <h4><xsl:text>Identifiers and Pagination:</xsl:text></h4>
        <b><xsl:text>Year: </xsl:text></b><xsl:value-of select="pub-date/year" /><br />
        <xsl:apply-templates select="volume" mode="front"/>
        <xsl:apply-templates select="issue" mode="front"/>
        <xsl:apply-templates select="fpage" mode="front"/>
        <xsl:apply-templates select="lpage" mode="front"/>
        <xsl:apply-templates select="article-id"/>
    
        <!-- contract information -->
        <xsl:if test="contract-num | contract-sponsor ">
            <xsl:apply-templates select="contract-num" mode="front"/>
            <xsl:apply-templates select="contract-sponsor" mode="front"/>
        </xsl:if>
        
        <!-- custom-meta wrap -->
        <xsl:if test="custom-meta-wrap">
            <xsl:apply-templates select="custom-meta-wrap"/>
        </xsl:if>
    </div>
    
    <div style="overflow:hidden; width:350px; float:right;">
        <h4><xsl:text>Article History:</xsl:text></h4>
        <xsl:apply-templates select="history/date" mode="front"/>
        <!-- pub-date -->
        <xsl:apply-templates select="pub-date" mode="front"/>
    </div>
    </div>
    <br />


    <div style="overflow:hidden;">
        
        <!-- article-level linking -->
        
        <xsl:choose>
        <xsl:when test="copyright-statement | permissions/copyright-statement">
            <b><xsl:apply-templates select="copyright-statement | permissions/copyright-statement" mode="front"/></b><br />
        </xsl:when>
        <xsl:otherwise>
            <xsl:if test="copyright-year | permissions/copyright-year">
                <xsl:text>Copyright: </xsl:text>
                <xsl:apply-templates select="copyright-year | permissions/copyright-year" mode="front"/>
                <xsl:apply-templates select="copyright-holder | permissions/copyright-holder"/>
            </xsl:if>
        </xsl:otherwise>
        </xsl:choose>
        <xsl:apply-templates select="license | permissions/license" mode="front"/>
    </div>
    <br />
	<br />

    <xsl:if test="author-notes">
    
						<xsl:apply-templates select="author-notes" mode="front"/>
						
					</xsl:if>
    
    <br />
<br />
   <hr/> 
</xsl:for-each>
<div>
	<a class="nounderline">
        <xsl:attribute name="href"><xsl:text>../../../ABSTRACT/</xsl:text><xsl:value-of select="$article"/></xsl:attribute>
        <div class="oabutton" onmouseover="this.className='oabutton_reverse'" onmouseout="this.className='oabutton'">
        View Abstract
        </div>
    </a>
    <xsl:text> </xsl:text>
    
    <xsl:variable name="jour3">../journal-meta/<xsl:value-of select="$journal"/>.xml</xsl:variable>
    
    <a class="nounderline" target="_blank">
        <xsl:attribute name="href"><xsl:text>../../../contents/pdf/</xsl:text><xsl:value-of select="$journal"/><xsl:text>/</xsl:text><xsl:value-of select="$article"/><xsl:text>.pdf</xsl:text>
        </xsl:attribute>
        <div class="oabutton" onmouseover="this.className='oabutton_reverse'" onmouseout="this.className='oabutton'">
        Download PDF
        </div>
    </a>
    <xsl:text> </xsl:text>
	<xsl:choose>
        <xsl:when test="document($jour3)/journal/@journal-epubs-enabled='yes' or document($volpath)/volume/@volume-epubs-enabled='yes'">
            <a class="nounderline" target="_blank">
                <xsl:attribute name="href"><xsl:text>../../../contents/epub/</xsl:text><xsl:value-of select="$journal"/><xsl:text>/</xsl:text><xsl:value-of select="$article"/><xsl:text>.epub</xsl:text>
        </xsl:attribute>
                <div class="oabutton" onmouseover="this.className='oabutton_reverse'" onmouseout="this.className='oabutton'">
                Download ePub
                </div>
            </a>
            <xsl:text> </xsl:text>
        </xsl:when>
    </xsl:choose>
    
    </div>
    <br />
    <hr/>
    </xsl:otherwise>
    </xsl:choose>
</xsl:template>


	<!-- ============================================================= -->
	<!--  9. MAKE-BODY                                                 -->
	<!-- ============================================================= -->

	<!-- initial context node is article -->

	<xsl:template name="make-body">
		<!-- change context node -->
		<xsl:for-each select="body">
			<xsl:apply-templates select="*[not(self::fn) and not(self::fn-group)]"/>
		</xsl:for-each>
	</xsl:template>


	<!-- ============================================================= -->
	<!--  10. MAKE-BACK                                                -->
	<!-- ============================================================= -->

	<!-- initial context node is article -->

	<xsl:template name="make-back">

		<!-- change context node to back -->
		<xsl:for-each select="back">
			<xsl:apply-templates select="title" />

			<xsl:if test="preceding-sibling::body//fn-group | .//fn-group">
				<h3>NOTES</h3>
				<xsl:apply-templates select="preceding-sibling::body//fn-group | .//fn-group"/>
				<xsl:call-template name="nl-1"/>
			</xsl:if>

			<xsl:apply-templates select="*[not(self::title) and not(self::fn-group)]"/>
			<xsl:call-template name="nl-1"/>
		</xsl:for-each>

	</xsl:template>



	<!-- ============================================================= -->
	<!--  11. MAKE-POST-PUBLICATION                                    -->
	<!-- ============================================================= -->


	<!-- At present the transform does not support
     subarticles and responses. To include that
     support in the present structure, fill out
     this template, call the "make-a-piece"
     template to ensure the details are handled
     in the same way and by the same templates
     as for the main article body. -->



	<!-- ============================================================= -->
	<!--  12. MAKE-END-METADATA                                        -->
	<!-- ============================================================= -->

	<!-- This metadata is displayed after the back and figs-and-tables
     because (when it it exists) it will be too long to display
     with the other metadata that is displayed before the body.    -->

	<!-- It is metadata for retrieval: categories, keywords, etc.      -->

	<!-- The context node when this template is called is the article
     or, when supported, the sub-article or response.              -->

	<xsl:template name="make-end-metadata">

		<!-- change context node -->
		<xsl:for-each select="front/article-meta">

			<xsl:if
				test="related-article
                | conference">

				

				<table width="100%" class="fm">

					<xsl:call-template name="table-setup-l-wide"/>

					<xsl:call-template name="nl-1"/>
					<tr>

						<xsl:call-template name="nl-1"/>
						<td colspan="2" valign="top">

							<!-- hierarchical subjects -->
							
							<!-- keyword group -->
							

							<!-- related article -->
							<xsl:apply-templates select="related-article"/>

							<!-- conference information -->
							<xsl:apply-templates select="conference"/>

						</td>
						<xsl:call-template name="nl-1"/>

					</tr>
					<xsl:call-template name="nl-1"/>

				</table>
				<xsl:call-template name="nl-1"/>

			</xsl:if>
		</xsl:for-each>

	</xsl:template>



	<!-- ============================================================= -->
	<!--  Article Categories                                           -->
	<!-- ============================================================= -->

	<xsl:template match="article-categories">
		<xsl:apply-templates/>
	</xsl:template>

	<xsl:template match="subj-group">
		<xsl:if test="not(parent::subj-group)">
			<span class="gen">
				<xsl:text>Article Categories:</xsl:text>
			</span>
		</xsl:if>
		<ul>
			<xsl:apply-templates/>
		</ul>
	</xsl:template>

	<xsl:template match="subject">
		<li>
			<xsl:apply-templates/>
		</li>
	</xsl:template>

	<!-- There may be many series-title elements; there
     may be one series-text (description) element. -->
	<xsl:template match="series-title">
		<xsl:if test="not(preceding-sibling::series-title)">
			<span class="gen">
				<xsl:text>Series: </xsl:text>
			</span>
		</xsl:if>
		<xsl:apply-templates/>
		<xsl:text>. </xsl:text>
		<xsl:if test="not(following-sibling::*)">
			<br/>
		</xsl:if>
	</xsl:template>

	<xsl:template match="series-text">
		<xsl:apply-templates/>
		<br/>
	</xsl:template>


	<!-- ============================================================= -->
	<!--  Keywords                                                     -->
	<!-- ============================================================= -->

	<!-- kwd-group and its kwd occur only in article-meta -->
	<xsl:template match="kwd-group">
		
			
			<xsl:choose>
			<xsl:when test="title">
			</xsl:when>
			<xsl:otherwise>
				<strong><xsl:text>Keywords: </xsl:text></strong>
			</xsl:otherwise>
		</xsl:choose>
			
			
			<xsl:apply-templates/>
		
		<br/>
	</xsl:template>

	<xsl:template match="kwd">
		
			<xsl:call-template name="make-id"/>
			<xsl:apply-templates/>
		

		<xsl:call-template name="make-keyword-punct"/>
	</xsl:template>

	<xsl:template name="make-keyword-punct">

		<xsl:choose>
			<xsl:when test="following-sibling::kwd">
				<xsl:text>, </xsl:text>
			</xsl:when>
			<xsl:otherwise>
				<xsl:text>.</xsl:text>
			</xsl:otherwise>
		</xsl:choose>

	</xsl:template>


	<!-- ============================================================= -->
	<!--  Related article                                              -->
	<!-- ============================================================= -->

	<xsl:template match="related-article">
		<xsl:choose>
			<xsl:when test="@xlink:href">
				<a>
					<xsl:call-template name="make-href"/>
					<xsl:call-template name="make-id"/>
					<span class="gen">
						<xsl:text>Related Article(s): </xsl:text>
					</span>
					<xsl:apply-templates/>
				</a>
			</xsl:when>
			<xsl:otherwise>
				<span class="gen">
					<xsl:call-template name="make-id"/>
					<xsl:text>Related Article(s): </xsl:text>
				</span>
				<xsl:apply-templates/>
			</xsl:otherwise>
		</xsl:choose>
		<br/>
	</xsl:template>

	<!-- ============================================================= -->
	<!--  Conference                                                   -->
	<!-- ============================================================= -->

	<xsl:template match="conference">
		<span class="gen">
			<xsl:text>Conference: </xsl:text>
		</span>
		<xsl:call-template name="make-conference"/>
		<br/>
	</xsl:template>

	<!-- doesn't use conf-num, conf-sponsor, conf-theme -->
	<xsl:template name="make-conference">

		<xsl:apply-templates select="conf-acronym" mode="add-period"/>
		<xsl:apply-templates select="conf-name" mode="add-period"/>
		<xsl:apply-templates select="conf-loc" mode="add-period"/>
		<xsl:apply-templates select="conf-date" mode="add-period"/>

	</xsl:template>

	<xsl:template match="*" mode="add-period">
		<xsl:apply-templates/>
		<xsl:text>. </xsl:text>
	</xsl:template>


	<!-- ============================================================= -->
	<!--  NARRATIVE CONTENT AND COMMON STRUCTURES                      -->
	<!-- ============================================================= -->

	<!-- ============================================================= -->
	<!--  13. PARAGRAPH WITH ITS SUBTLETIES                            -->
	<!-- ============================================================= -->

	<xsl:template match="p">
		<xsl:choose>
			<xsl:when test="parent::list-item">
				<xsl:apply-templates/>
				<xsl:if test="following-sibling::p">
					<br/>
				</xsl:if>
			</xsl:when>
			<xsl:otherwise>
				<p>
					<xsl:call-template name="make-id"/>
					<xsl:apply-templates/>
				</p>
			</xsl:otherwise>
		</xsl:choose>
		<xsl:call-template name="nl-1"/>
	</xsl:template>

	<!-- The first p in a footnote displays the fn symbol or,
     if no symbol, the fn ID -->
	<xsl:template match="fn/p[1]">
		<p>
			<xsl:call-template name="make-id"/>
			<xsl:choose>
				<xsl:when test="preceding-sibling::label">
					<span class="fn-label">
						<sup><xsl:value-of select="preceding-sibling::label"/><xsl:text>&#160;</xsl:text></sup>
					</span>
				</xsl:when>
				<xsl:when test="../@symbol">
					<span class="fn-label">
						<xsl:value-of select="../@symbol"/>
					</span>
				</xsl:when>
				<xsl:when test="../@id">
					
				</xsl:when>
			</xsl:choose>
			<xsl:apply-templates/>
		</p>
	</xsl:template>

	<xsl:template match="speech/p[1]">
		<p>
			<xsl:call-template name="make-id"/>
			<xsl:apply-templates select="preceding-sibling::speaker" mode="show-it-here"/>
			<xsl:text> </xsl:text>
			<xsl:apply-templates/>
		</p>
	</xsl:template>

	<!-- prevent the first def/p from causing a p tag
     which would display an unwanted break -->
	<xsl:template match="def/p[1]">
		<span class="capture-id">
			<xsl:call-template name="make-id"/>
			<xsl:apply-templates/>
		</span>
	</xsl:template>


	<!-- ============================================================= -->
	<!--  14. SECTION                                                  -->
	<!-- ============================================================= -->

	<!-- the first body/sec puts out no rule at its top,
     because body already puts out a part-rule at its top;
     subsequent body/secs do put out a section-rule -->
	<xsl:template match="body/sec">
		<xsl:call-template name="nl-1"/>

		<xsl:if test="position()>'1'">
			
			<xsl:call-template name="nl-1"/>
		</xsl:if>

		<div>
			<xsl:call-template name="make-id"/>
			<xsl:apply-templates/>
		</div>
		<xsl:call-template name="nl-1"/>
	</xsl:template>

	<!-- no other level of sec puts out a rule -->
	<xsl:template match="sec">
		<xsl:choose>
			<xsl:when test="@sec-type='display-objects'"/>
			<xsl:otherwise>
				<div>
					<xsl:call-template name="make-id"/>
					<xsl:apply-templates select="*[not(self::fn) and not(self::fn-group)]"/>
				</div>
				<xsl:call-template name="nl-1"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>


	<!-- ============================================================= -->
	<!--  15. LIST and its Internals                                   -->
	<!-- ============================================================= -->

	<xsl:template match="list">
		<xsl:call-template name="nl-1"/>
		<xsl:call-template name="make-anchor"/>
		<xsl:if test="label | title">
			<xsl:apply-templates select="label | title"/>
		</xsl:if>
		<xsl:choose>
			<xsl:when test="@list-type='simple' or list-item/label">
				<ul style="list-style-type: none;">
					<xsl:call-template name="nl-1"/>
					<xsl:apply-templates select="list-item"/>
					<xsl:call-template name="nl-1"/>
				</ul>
			</xsl:when>
			<xsl:when test="@list-type='bullet'">
				<xsl:call-template name="nl-1"/>
				<ul>
					<xsl:call-template name="nl-1"/>
					<xsl:apply-templates select="list-item"/>
					<xsl:call-template name="nl-1"/>
				</ul>
			</xsl:when>
			<xsl:otherwise>
				<xsl:call-template name="nl-1"/>
				<ol>
					<xsl:call-template name="nl-1"/>
					<xsl:apply-templates select="list-item"/>
					<xsl:call-template name="nl-1"/>
				</ol>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<xsl:template match="list-item">
		<xsl:call-template name="nl-1"/>
		<li>
			<xsl:apply-templates/>
		</li>
		<xsl:call-template name="nl-1"/>
	</xsl:template>


	<!-- ============================================================= -->
	<!--  16. DISPLAY-QUOTE                                            -->
	<!-- ============================================================= -->

	<xsl:template match="disp-quote">
		<xsl:call-template name="nl-1"/>
		<blockquote>
			<xsl:call-template name="make-id"/>
			<xsl:apply-templates/>
		</blockquote>
		<xsl:call-template name="nl-1"/>
	</xsl:template>


	<!-- ============================================================= -->
	<!--  17. SPEECH and its internals                                 -->
	<!-- ============================================================= -->

	<!-- first p will pull in the speaker
     in mode "show-it-here" -->
	<xsl:template match="speech">
		<blockquote>
			<xsl:call-template name="make-id"/>
			<xsl:call-template name="nl-1"/>
			<xsl:apply-templates/>
			<xsl:call-template name="nl-1"/>
		</blockquote>
	</xsl:template>

	<xsl:template match="speaker" mode="show-it-here">
		<b>
			<xsl:apply-templates/>
		</b>
	</xsl:template>

	<!-- in no mode -->
	<xsl:template match="speaker"/>


	<!-- ============================================================= -->
	<!--  18. STATEMENT and its internals                              -->
	<!-- ============================================================= -->

	<xsl:template match="statement">
		<div class="capture-id">
			<xsl:call-template name="make-id"/>
			<xsl:call-template name="nl-1"/>
			<xsl:apply-templates/>
		</div>
	</xsl:template>

	<xsl:template match="statement/label | statement/title">
		<xsl:call-template name="nl-1"/>
		<p>
			<b>
				<xsl:apply-templates/>
			</b>
		</p>
		<xsl:call-template name="nl-1"/>
	</xsl:template>

<xsl:template match="aff/label">
		<sup><xsl:apply-templates/></sup>
		<xsl:text> </xsl:text>
	</xsl:template>
	
<xsl:template match="corresp/label">
		<sup><xsl:apply-templates/></sup>
		<xsl:text> </xsl:text>
	</xsl:template>

	<!-- ============================================================= -->
	<!--  19. VERSE-GROUP and its internals                            -->
	<!-- ============================================================= -->

	<xsl:template match="verse-group">
		<xsl:call-template name="nl-1"/>
		<blockquote>
			<xsl:call-template name="make-id"/>
			<xsl:apply-templates/>
		</blockquote>
	</xsl:template>

	<xsl:template match="verse-line">
		<xsl:call-template name="nl-1"/>
		<xsl:apply-templates/>
		<br/>
	</xsl:template>


	<!-- ============================================================= -->
	<!--  20. BOXED-TEXT                                               -->
	<!-- ============================================================= -->

	<xsl:template match="boxed-text">

		<xsl:call-template name="nl-1"/>

		<table border="4" cellpadding="10pt" width="100%">
			<xsl:call-template name="make-id"/>

			<!-- the box is achieved by means of a table, and
         tables don't seem to inherit class attributes,
         so we repeat the class attribute here -->

			<xsl:attribute name="class">
				<xsl:choose>
					<xsl:when test="ancestor::front">fm</xsl:when>
					<xsl:when test="ancestor::body">body</xsl:when>
					<xsl:when test="ancestor::back">bm</xsl:when>
					<xsl:otherwise>body</xsl:otherwise>
				</xsl:choose>
			</xsl:attribute>

			<xsl:call-template name="nl-1"/>
			<tr>
				<td valign="top">
					<xsl:apply-templates/>
				</td>
			</tr>

		</table>

	</xsl:template>


	<!-- ============================================================= -->
	<!--  21. PREFORMAT                                                -->
	<!-- ============================================================= -->


	<xsl:template match="preformat" name="format-as-line-for-line">
		<pre><xsl:call-template name="make-id"/><xsl:apply-templates/></pre>
	</xsl:template>


	<!-- ============================================================= -->
	<!--  22. SUPPLEMENTARY MATERIAL                                   -->
	<!-- ============================================================= -->

	<xsl:template match="supplementary-material">
		<xsl:apply-templates/>
	</xsl:template>


	<!-- ============================================================= -->
	<!--  23. DISPLAY FORMULA, CHEM-STRUCT-WRAPPER                     -->
	<!-- ============================================================= -->

	<!-- both are grouping elements to keep parts together -->
	<xsl:template match="disp-formula | chem-struct-wrapper">
		<div class="capture-id">
			<xsl:call-template name="make-id"/>
			<xsl:call-template name="display-id"/>
			<br/>
			<xsl:apply-templates/>
		</div>
	</xsl:template>


	<!-- ============================================================= -->
	<!--  24. FORMATTING ELEMENTS                                      -->
	<!-- ============================================================= -->

	<xsl:template match="bold">
		<b>
			<xsl:apply-templates/>
		</b>
	</xsl:template>

	<xsl:template match="italic">
		<i>
			<xsl:apply-templates/>
		</i>
	</xsl:template>

	<xsl:template match="bold" mode="vancouver">
		<strong>
			<xsl:apply-templates/>
		</strong>
	</xsl:template>

	<xsl:template match="italic" mode="vancouver">
		<em>
			<xsl:apply-templates/>
		</em>
	</xsl:template>
    
    <xsl:template match="bold" mode="ieee">
		<strong>
			<xsl:apply-templates/>
		</strong>
	</xsl:template>

	<xsl:template match="italic" mode="ieee">
		<em>
			<xsl:apply-templates/>
		</em>
	</xsl:template>

	<xsl:template match="bold" mode="apa">
		<strong>
			<xsl:apply-templates/>
		</strong>
	</xsl:template>
	
	<xsl:template match="bold" mode="harvard">
		<strong>
			<xsl:apply-templates/>
		</strong>
	</xsl:template>

	<xsl:template match="italic" mode="apa">
		<em>
			<xsl:apply-templates/>
		</em>
	</xsl:template>
	
	<xsl:template match="italic" mode="harvard">
		<em>
			<xsl:apply-templates/>
		</em>
	</xsl:template>
	
    <xsl:template match="bold" mode="acs">
		<strong>
			<xsl:apply-templates/>
		</strong>
	</xsl:template>

	<xsl:template match="italic" mode="acs">
		<em>
			<xsl:apply-templates/>
		</em>
	</xsl:template>

	<xsl:template match="monospace">
		<span class="monospace">
			<xsl:apply-templates/>
		</span>
	</xsl:template>

	<xsl:template match="overline">
		<span class="overline">
			<xsl:apply-templates/>
		</span>
	</xsl:template>

	<xsl:template match="sc">

		<!-- handle any tags as usual, until
       we're down to the text strings -->
		<small>
			<xsl:apply-templates/>
		</small>
	</xsl:template>

	<xsl:template match="sc//text()">
		<xsl:param name="str" select="."/>

		<xsl:call-template name="capitalize">
			<xsl:with-param name="str" select="$str"/>
		</xsl:call-template>
	</xsl:template>

	<xsl:template match="strike">
		<s>
			<xsl:apply-templates/>
		</s>
	</xsl:template>

	<xsl:template match="sub">
		<sub>
			<xsl:apply-templates/>
		</sub>
	</xsl:template>

	<xsl:template match="sup">
		<sup>
			<xsl:apply-templates/>
		</sup>
	</xsl:template>

	<xsl:template match="underline">
		<span class="underline">
			<xsl:apply-templates/>
		</span>
	</xsl:template>

	<!-- ============================================================= -->
	<!--  25. SEMANTIC ELEMENTS                                        -->
	<!-- ============================================================= -->

	<xsl:template match="abbrev">
		<xsl:choose>
			<xsl:when test="@xlink:href">
				<a>
					<xsl:call-template name="make-href"/>
					<xsl:call-template name="make-id"/>
					<xsl:apply-templates/>
				</a>
			</xsl:when>
			<xsl:otherwise>
				<span class="capture-id">
					<xsl:call-template name="make-id"/>
					<xsl:apply-templates/>
				</span>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<xsl:template match="inline-graphic">
		<xsl:call-template name="nl-1"/>
		<img>
			<xsl:call-template name="make-src"/>
			<xsl:call-template name="make-id"/>
		</img>
	</xsl:template>

	<xsl:template match="inline-formula">
		<span class="capture-id">
			<xsl:call-template name="make-id"/>
			<xsl:apply-templates/>
		</span>
	</xsl:template>

	<!-- is meant be a link: we assume the xlink:href
     attribute is used, although it is not
     required by the DTD. -->
	<xsl:template match="inline-supplementary-material">
		<xsl:call-template name="nl-1"/>
		<a>
			<xsl:call-template name="make-href"/>
			<xsl:call-template name="make-id"/>
			<xsl:apply-templates/>
		</a>
	</xsl:template>

	<xsl:template match="glyph-data">
		<xsl:call-template name="nl-1"/>
		<span class="take-note">
			<xsl:call-template name="make-id"/>
			<xsl:text>[glyph data here: ID=</xsl:text>
			<xsl:value-of select="@id"/>
			<xsl:text>]</xsl:text>
		</span>
	</xsl:template>

	<!-- ============================================================= -->
	<!--  Named Content                                                -->
	<!-- ============================================================= -->

	<xsl:template match="named-content">
		<xsl:choose>
			<xsl:when test="@xlink:href">
				<a>
					<xsl:call-template name="make-href"/>
					<xsl:call-template name="make-id"/>
					<span class="gen">
						<xsl:text>[</xsl:text>
						<xsl:value-of select="@content-type"/>
						<xsl:apply-templates/>
						<xsl:text>]</xsl:text>
					</span>
				</a>
			</xsl:when>
			<xsl:otherwise>
				<span class="capture-id">
					<xsl:call-template name="make-id"/>
					<span class="gen">
						<xsl:text>[</xsl:text>
						<xsl:value-of select="@content-type"/>
						<xsl:text>: </xsl:text>
					</span>
					<xsl:apply-templates/>
					<span class="gen">
						<xsl:text>]</xsl:text>
					</span>
				</span>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>


	<!-- ============================================================= -->
	<!--  26. BREAK AND HORIZONTAL RULE                                -->
	<!-- ============================================================= -->

	<xsl:template match="break" name="make-break">
		<br/>
		<xsl:call-template name="nl-1"/>
	</xsl:template>

	<xsl:template match="hr" name="make-rule">
		<xsl:call-template name="nl-1"/>
		<hr/>
		<xsl:call-template name="nl-1"/>
	</xsl:template>



	<!-- ============================================================= -->
	<!--  27. CHEM-STRUCT                                              -->
	<!-- ============================================================= -->

	<xsl:template match="chem-struct">

		<span class="capture-id">
			<xsl:call-template name="make-id"/>
			<xsl:call-template name="display-id"/>

			<xsl:choose>
				<xsl:when test="@xlink:href">
					<a>
						<xsl:call-template name="make-href"/>
						<xsl:apply-templates/>
					</a>
				</xsl:when>
				<xsl:otherwise>
					<xsl:apply-templates/>
				</xsl:otherwise>
			</xsl:choose>

		</span>
	</xsl:template>


	<!-- ============================================================= -->
	<!--  28. TEX-MATH and MML:MATH                                    -->
	<!-- ============================================================= -->

	<xsl:template match="tex-math">
		<span class="take-note">
			<xsl:text>[</xsl:text>
			<xsl:copy-of select="."/>
			<xsl:text>]</xsl:text>
		</span>
	</xsl:template>


	<!-- can presume this is meant to be inline -->
	<xsl:template match="inline-formula//mml:math">
		<xsl:choose>
			<xsl:when test="@xlink:href">
				<a>
					<xsl:call-template name="make-href"/>
					<xsl:call-template name="make-id"/>
					<xsl:apply-templates/>
				</a>
			</xsl:when>
			<xsl:otherwise>
				<span class="capture-id">
					<xsl:call-template name="make-id"/>
					<xsl:apply-templates/>
				</span>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<!-- we don't -know- mml:math in general to be inline,
     so treat it as block.
     Put it in a table to get a pretty border. -->
	<xsl:template match="mml:math">
		<xsl:param name="mathID" select="@id"/>
		<xsl:choose>

			<xsl:when test="@xlink:href">
				<table border="0">
					<tr>
						<td valign="top">
							
								<xsl:call-template name="make-href"/>
								<xsl:call-template name="make-id"/>
							<xsl:if test="@id=$mathID">

							<span style="display:none;">
							<xsl:attribute name="id"><xsl:value-of select="$mathID" />
							</xsl:attribute>
							<mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML">
								<xsl:for-each select="./mml:*"> 
								  <xsl:copy-of select="."/>
								</xsl:for-each> 
								</mml:math>
							</span>
</xsl:if>
						</td>
					</tr>
				</table>
			</xsl:when>

			<xsl:otherwise>
			
				
							
							
							<xsl:if test="@id=$mathID">

							<span style="display:none;">
							<xsl:attribute name="id"><xsl:value-of select="$mathID" />
							</xsl:attribute>
							<mml:math xmlns:mml="http://www.w3.org/1998/Math/MathML">
								<xsl:for-each select="./mml:*"> 
								  <xsl:copy-of select="."/>
								</xsl:for-each> 
								</mml:math>
							</span>
</xsl:if>

						
			</xsl:otherwise>
		</xsl:choose>

	</xsl:template>


	<!-- ============================================================= -->
	<!--  29. GRAPHIC and MEDIA                                        -->
	<!-- ============================================================= -->

	<xsl:template match="graphic">
		
		
		<img>
        	
			<xsl:call-template name="make-src"/>
			<xsl:call-template name="make-id"/>
		</img>
		
		<xsl:apply-templates/>
	</xsl:template>



	<xsl:template match="media">
		<a>
			<xsl:attribute name="href">
            	<xsl:text>../../../../../contents/supplementary-material/</xsl:text><xsl:value-of select="./@xlink:href"/>
            </xsl:attribute>
			<div class="oabutton" onmouseover="this.className='oabutton_reverse'" onmouseout="this.className='oabutton'">
            Download File
            </div>
		</a>
        <br />
        <br />
	</xsl:template>


	<!-- ============================================================= -->
	<!--  30. ARRAY                                                    -->
	<!-- ============================================================= -->

	<xsl:template match="array">
		<hr width="40%" align="left" noshade="1"/>
		<xsl:call-template name="nl-1"/>

		<table>
			<xsl:call-template name="make-id"/>
			<xsl:apply-templates/>
			<xsl:call-template name="nl-1"/>
		</table>
		<xsl:call-template name="nl-1"/>

		<hr width="40%" align="left" noshade="1"/>
		<xsl:call-template name="nl-1"/>
	</xsl:template>


	<!-- ============================================================= -->
	<!--  31. CAPTIONING                                               -->
	<!-- ============================================================= -->

	<!-- the chooses before and after the element content
     tweak the display as appropriate -->

	<xsl:template match="alt-text | attrib">

		<!-- element-specific handling before content: -->
		<xsl:choose>

			<!-- alt-text gets a generated label-->
			<xsl:when test="self::alt-text">
				<xsl:if test="not(ancestor::fig)
                  and not(ancestor::table)">
					<br/>
				</xsl:if>

				<span class="gen">
					<xsl:call-template name="make-id"/>
					<xsl:text>Alternate Text: </xsl:text>
				</span>
			</xsl:when>

			<!-- attrib is preceded by spaces plus em-dash -->
			<xsl:when test="self::attrib">
				<xsl:text>&#8194;&#8194;&#8212;</xsl:text>
			</xsl:when>
		</xsl:choose>

		<xsl:apply-templates/>
		<xsl:text>. </xsl:text>

		<!-- element-specific handling after content: -->
		<xsl:choose>

			<!-- alt-text and long-desc get a break after -->
			<xsl:when test="self::alt-text | self::long-desc">
				<br/>
			</xsl:when>

		</xsl:choose>

	</xsl:template>
	
	<xsl:template match="label">
		<xsl:choose>
			<xsl:when test="parent::aff | parent::author-notes | parent::corresp">
				<span class="au-label">
					<xsl:apply-templates/>
				</span>
			</xsl:when>
			<xsl:when test="parent::fn">
				<!-- class fn-label = class au-label -->
				<span class="fn-label">
					<sup><xsl:apply-templates/></sup>
				</span>
			</xsl:when>
            <xsl:when test="parent::fig">
					<b><xsl:apply-templates/></b><br />

			</xsl:when>
            <xsl:when test="parent::table-wrap | parent::table-wrap-group">
					<b><xsl:apply-templates/></b><br />

			</xsl:when>
            <xsl:when test="parent::sec">
					
			</xsl:when>
			<xsl:otherwise>
				<span class="label">
					<xsl:apply-templates/>&#xA0;
				</span>
			</xsl:otherwise>
		</xsl:choose>		
	</xsl:template>
	
	<!-- These are handled inside ref -->
	<!-- <xsl:template match="label" mode="none"/> -->
    
	<xsl:template match="label" mode="nscitation"/>

<xsl:template match="fig/caption">
			<xsl:call-template name="make-id"/>
			<xsl:apply-templates/>
	</xsl:template>

	<xsl:template match="caption">
		<span class="capture-id">
			<xsl:call-template name="make-id"/>
			<xsl:apply-templates/>
		</span>
		<br/>
	</xsl:template>


	<!-- mixed-content; used in figures, tables, etc. -->
	<xsl:template match="long-desc">
		<span class="capture-id">
			<xsl:call-template name="make-id"/>
			<xsl:apply-templates/>
		</span>
		<br/>
	</xsl:template>

	<xsl:template match="object-id">
		<xsl:choose>
			<xsl:when test="@pub-id-type">
				<xsl:value-of select="@pub-id-type"/>
			</xsl:when>
			<xsl:otherwise>
				<span class="gen">
					<xsl:text>Object ID</xsl:text>
				</span>
			</xsl:otherwise>
		</xsl:choose>

		<xsl:text>: </xsl:text>
		<xsl:apply-templates/>
		<xsl:text>. </xsl:text>
		<br/>
	</xsl:template>


	<!-- ============================================================= -->
	<!--  32. FIGURE, MODE PUT-AT-END                                  -->
	<!-- ============================================================= -->

	<xsl:template match="fig-group">
    	<div class="curve_frame" style="border: outset; padding:10px;  overflow:hidden;">
        <xsl:apply-templates/>
        </div>
        <br />
    <br />
    </xsl:template>

	<xsl:template match="fig">
    <xsl:param name="figure" select="@id"/>
    <a rel="facebox" class="popper">
    
    	<xsl:attribute name="data-popbox">
			<xsl:value-of select="/article/front/article-meta/article-id" /><xsl:text>_</xsl:text><xsl:value-of select="$figure"/>
		</xsl:attribute>
    
        <xsl:attribute name="href">
            <xsl:text>../../../FULLTEXT/</xsl:text><xsl:value-of select="/article/front/article-meta/article-id" /><xsl:text>/FIGURE/</xsl:text><xsl:value-of select="$figure" /><xsl:text>/</xsl:text>
        </xsl:attribute>
        <table class="silver" style=" border: outset; padding-left:10px; padding-right:10px; padding-top:0px; padding-bottom:10px;">
            <tr>
            <td style="padding-left:5px; padding-right:5px; padding-top:5px; padding-bottom:5px;">
                <img style="border:thin; border-style:solid;" width="120">
                    <xsl:attribute name="src">
                        <xsl:text>../../../contents/figures/</xsl:text><xsl:value-of select="/article/front/journal-meta/journal-id" /><xsl:text>/</xsl:text><xsl:value-of select="/article/front/article-meta/article-id" /><xsl:text>_</xsl:text><xsl:value-of select="@id" /><xsl:text>.jpg</xsl:text>
                    </xsl:attribute>
                </img>
            </td>
            <td valign="top" style="padding-left:5px; padding-right:5px; padding-top:5px; padding-bottom:5px; color:#000000;">
                <span>
                    <xsl:call-template name="make-id"/>
                </span>
                <xsl:apply-templates select="child::*[not(self::graphic) and not(self::table-wrap) and not(self::table)]"/>
            </td>
            </tr>
        </table>
    </a>
    
    <div class="popbox" style="position:fixed; top:50px; left:350px;">
		<xsl:attribute name="id">
			<xsl:value-of select="/article/front/article-meta/article-id" /><xsl:text>_</xsl:text><xsl:value-of select="$figure"/>
		</xsl:attribute>
	    <!--
	    <div style="overflow:hidden;">
			<div style="overflow:hidden; width:95%; padding:8px; text-align:justify; background:#ffffff; -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px; border:#cccccc solid thin;">
			-->
				<img width="350">
					<xsl:attribute name="src">
		            	<xsl:text>../../../../../../../../contents/figures/</xsl:text><xsl:value-of select="/article/front/journal-meta/journal-id" /><xsl:text>/</xsl:text><xsl:value-of select="graphic/@xlink:href"/>
		            </xsl:attribute>
	            </img>
			<!--
			</div>
		</div>
		-->
	</div>
    
    
    <br />
	<br />
    
	</xsl:template>

	<!-- each figure is a row -->



	<!-- ============================================================= -->
	<!--  33. TABLE-WRAP, MODE PUT-AT-END                              -->
	<!-- ============================================================= -->

	<xsl:template match="table-wrap-group">
    	<div class="curve_frame" style="border: outset; padding:10px;  overflow:hidden;">
        <xsl:apply-templates/>
        </div>
        <br />
    <br />
    </xsl:template>

	<xsl:template match="table-wrap">
		<xsl:param name="table" select="@id"/>
    <a rel="facebox">
        <xsl:attribute name="href">
            <xsl:text>../../../FULLTEXT/</xsl:text><xsl:value-of select="/article/front/article-meta/article-id" /><xsl:text>/TABLE/</xsl:text><xsl:value-of select="$table" /><xsl:text>/</xsl:text>
        </xsl:attribute>
        <div class="silver" style="border: outset; padding-left:10px; padding-right:10px; padding-top:0px; padding-bottom:10px; overflow:hidden;">
            <div style="padding-left:5px; padding-right:5px; padding-top:5px; padding-bottom:5px; float:left; overflow:hidden;">
                <img style="border:thin; border-style:solid;">
                    <xsl:attribute name="src">
                        <xsl:text>../../../contents/images/</xsl:text><xsl:value-of select="/article/front/journal-meta/journal-id" /><xsl:text>/</xsl:text><xsl:value-of select="/article/front/article-meta/article-id" /><xsl:text>_</xsl:text><xsl:value-of select="@id" /><xsl:text>_thumb.gif</xsl:text>
                    </xsl:attribute>
                </img>
            </div>
            <div style="padding-left:5px; padding-right:5px; padding-top:5px; padding-bottom:5px; overflow:hidden;">
                <span class="gen">
					<xsl:call-template name="make-id"/>
				</span>
				<xsl:apply-templates select="child::*[not(self::table or self::table-wrap-foot)]"/>
            </div>
        </div>
    </a>
    <br />
    <br />
	</xsl:template>

	


	<xsl:template match="table">
		<table width="100%" class="bm">

			<xsl:if test="@frame">
				<xsl:attribute name="frame">
					<xsl:value-of select="@frame"/>
				</xsl:attribute>
			</xsl:if>
			<xsl:if test="@rules">
				<xsl:attribute name="rules">
					<xsl:value-of select="@rules"/>
				</xsl:attribute>
			</xsl:if>
			<xsl:call-template name="nl-1"/>

			<xsl:apply-templates/>
			<xsl:call-template name="nl-1"/>
		</table>
		<xsl:call-template name="nl-1"/>
	</xsl:template>

	<xsl:template match="thead">
		<thead>
			<xsl:call-template name="make-id"/>
			<xsl:apply-templates/>
		</thead>
		<xsl:call-template name="nl-1"/>
	</xsl:template>

	<xsl:template match="th">
		<th>
			<xsl:call-template name="make-id"/>
			<xsl:for-each select="@*">
				<xsl:attribute name="{name(.)}">
					<xsl:value-of select="."/>
				</xsl:attribute>
			</xsl:for-each>
			<xsl:apply-templates/>
		</th>
		<xsl:call-template name="nl-1"/>
	</xsl:template>

	<xsl:template match="tr">
		<tr>
			<xsl:call-template name="make-id"/>
			<xsl:apply-templates/>
		</tr>
		<xsl:call-template name="nl-1"/>
	</xsl:template>

	<xsl:template match="td">
		<td valign="top">
			<xsl:call-template name="make-id"/>
			<xsl:for-each select="@*">
				<xsl:attribute name="{name(.)}">
					<xsl:value-of select="."/>
				</xsl:attribute>
			</xsl:for-each>
			<xsl:apply-templates/>
		</td>
		<xsl:call-template name="nl-1"/>
	</xsl:template>

	<xsl:template match="tfoot | table-wrap-foot">
		<div class="capture-id">
			<xsl:call-template name="make-id"/>
			<xsl:apply-templates/>
		</div>
		<xsl:call-template name="nl-1"/>
	</xsl:template>



	<!-- ============================================================= -->
	<!-- MODE front                                                    -->
	<!-- ============================================================= -->

	<!--
<xsl:template match="journal-meta/journal-id
                   | journal-meta/journal-title
                   | journal-meta/journal-abbrev-title
                   | journal-meta/publisher"/>
-->

	<!-- ============================================================= -->
	<!--  34) JOURNAL-META (in order of appearance in output)          -->
	<!-- ============================================================= -->

	<!-- journal-id -->

	<xsl:template match="journal-id[@journal-id-type]" mode="front">
		<b>
		<span class="gen">
			<xsl:text>Journal ID (</xsl:text>
		</span>
		<xsl:value-of select="@journal-id-type"/>
		<span class="gen">
			<xsl:text>): </xsl:text>
		</span>
		</b>
		<xsl:value-of select="."/>
		<br/>
		<xsl:call-template name="nl-1"/>
	</xsl:template>

	<xsl:template match="journal-title" mode="front">
		<span class="gen">
			<b><xsl:text>Journal Name: </xsl:text></b>
		</span>
		<xsl:apply-templates/>
		<br/>
		<xsl:call-template name="nl-1"/>
	</xsl:template>

	<!-- abbrev-journal-title -->

	<xsl:template match="abbrev-journal-title" mode="front">
		<span class="gen">
			<b><xsl:text>Journal Abbreviation: </xsl:text></b>
		</span>
		<xsl:apply-templates/>
		<br/>
		<xsl:call-template name="nl-1"/>
	</xsl:template>

	<!-- issn -->

	<xsl:template match="issn" mode="front">
		<xsl:choose>
		<xsl:when test="@pub-type='epub'">
		<span class="gen">
			<b><xsl:text>ISSN (Online): </xsl:text></b>
		</span>
		</xsl:when>
		<xsl:when test="@pub-type='ppub'">
		<span class="gen">
			<b><xsl:text>ISSN (Print): </xsl:text></b>
		</span>
		</xsl:when>
		</xsl:choose>
		<xsl:apply-templates/>
		<br/>
		<xsl:call-template name="nl-1"/>
	</xsl:template>

	<!-- publisher -->
	<!-- required name, optional location -->

	<xsl:template match="publisher" mode="front">
		<xsl:apply-templates mode="front"/>
		<br/>
		<xsl:call-template name="nl-1"/>
	</xsl:template>

	<xsl:template match="publisher-name" mode="front">
		<span class="gen">
			<b><xsl:text>Publisher: </xsl:text></b>
		</span>
		<xsl:apply-templates/>
	</xsl:template>

	<xsl:template match="publisher-loc" mode="front">
		<!-- if present, follows a publisher-name, so produces a comma -->
		<xsl:text>, </xsl:text>
		<xsl:apply-templates/>
	</xsl:template>

	<!-- notes -->

	<xsl:template match="notes" mode="front">
		<span class="gen">Notes: </span>
		<xsl:apply-templates/>
		<br/>
		<xsl:call-template name="nl-1"/>
	</xsl:template>


	<!-- ============================================================= -->
	<!--  35) ARTICLE-META (in order of appearance in output)          -->
	<!-- ============================================================= -->

	<!-- ext-link -->

	<xsl:template match="ext-link" mode="front">
		<span class="gen">
			<xsl:call-template name="make-id"/>
			<xsl:text>Link: </xsl:text>
		</span>
		<xsl:apply-templates/>
		<br/>
		<xsl:call-template name="nl-1"/>
	</xsl:template>

	<!-- supplementary-material -->

	<!-- Begins with:
    Object Identifier <object-id>, zero or more
    Label (Of a Figure, Reference, Etc.) <label>, zero or one
    Caption of a Figure, Table, Etc. <caption>, zero or one
    Any combination of:
      All the accessibility elements:
        Alternate Title Text (For a Figure, Etc.) <alt-text>
        Long Description <long-desc>
      All the address linking elements:
        Email Address <email>
        External Link <ext-link>
        Uniform Resource Indicator (URI) <uri>

  Then an ordinary combination of para-level elements

  Ending with:
    Any combination of:
    Attribution <attrib>
    Copyright Statement <copyright-statement>
-->

	<xsl:template match="supplementary-material" mode="front">
            <xsl:apply-templates/>
	</xsl:template>

	<!-- self-uri -->

	<xsl:template match="self-uri" mode="front">
		<span class="gen">
			<xsl:text>Self URI: </xsl:text>
		</span>
		<a href="{@xlink:href}">
			<xsl:choose>
				<xsl:when test="*|text()">
					<xsl:apply-templates/>
				</xsl:when>
				<xsl:otherwise>
					<xsl:value-of select="@xlink:href"/>
				</xsl:otherwise>
			</xsl:choose>
		</a>
		<br/>
		<xsl:call-template name="nl-1"/>
	</xsl:template>
	
	<!-- product -->
	<!-- uses mode="product" within -->

	<xsl:template match="product" mode="front">
		<xsl:choose>
			<xsl:when test="@xlink:href">
				<a>
					<xsl:call-template name="make-href"/>
					<span class="gen">
						<xsl:text>Product Information: </xsl:text>
					</span>
					<xsl:apply-templates mode="product"/>
				</a>
			</xsl:when>
			<xsl:otherwise>
				<span class="gen">
					<xsl:text>Product Information: </xsl:text>
				</span>
				<xsl:apply-templates mode="product"/>
			</xsl:otherwise>
		</xsl:choose>
		<br/>
		<br/>
		<xsl:call-template name="nl-1"/>
	</xsl:template>

	<!-- The product element allows a mixed-content model,
     but perhaps sometimes only element nodes will be used.
     Rough test:
       - if the next sibling is another element,
         add a space to make the content somewhat legible. -->
	<xsl:template match="*" mode="product">

		<xsl:apply-templates/>

		<xsl:if test="generate-id(following-sibling::node()[1])
                 =generate-id(following-sibling::*[1])">
			<xsl:text> </xsl:text>
		</xsl:if>

	</xsl:template>

	<!-- copyright-statement, copyright-year, copyright-holder -->

	<xsl:template match="copyright-statement | copyright-year | copyright-holder" mode="front">
		<xsl:apply-templates/>
		<xsl:call-template name="nl-1"/>
	</xsl:template>
	
	<!-- license whether or not part of permissions -->
	<xsl:template match="license" mode="front">
		<br/>
		<xsl:choose>
			<xsl:when test="@license-type">
				<span class="gen" style="text-transform:capitalize"><xsl:value-of select="@license-type"/> license: </span>
			</xsl:when>
			<xsl:otherwise>
				<span class="gen">License: </span>
			</xsl:otherwise>
		</xsl:choose>
		<xsl:apply-templates select="p/* | p/text()"/>
	</xsl:template>

	<!-- history -->

	<xsl:template match="history/date" mode="front">

		<xsl:variable name="the-type">
			<xsl:choose>
				<xsl:when test="@date-type='accepted'">Acceptance Date:</xsl:when>
				<xsl:when test="@date-type='received'">Received Date:</xsl:when>
				<xsl:when test="@date-type='rev-request'">Revision Requested Date:</xsl:when>
				<xsl:when test="@date-type='rev-recd'">Revision Received Date:</xsl:when>
			</xsl:choose>
		</xsl:variable>

		<xsl:if test="@date-type">
				<strong><xsl:value-of select="$the-type"/></strong>
				<xsl:text> </xsl:text>
		</xsl:if>

		<xsl:apply-templates/>
		<br/>
	</xsl:template>

	<!-- pub-date -->

	<xsl:template match="pub-date" mode="front">
		<xsl:choose>
			<xsl:when test="@pub-type='ppub'">
				<strong>Print publication date: </strong>
			</xsl:when>
			<xsl:when test="@pub-type='epub'">
				<strong>Electronic publication date: </strong>
			</xsl:when>
			<xsl:when test="@pub-type='collection'">
				<strong>Collection year: </strong>
			</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="@pub-type"/>
			</xsl:otherwise>
		</xsl:choose>

		<span class="gen">
			<xsl:text></xsl:text>
		</span>
		<xsl:apply-templates/>
		<br/>
		<xsl:call-template name="nl-1"/>
	</xsl:template>

	<!-- volume -->

	<xsl:template match="volume" mode="front">
		<span class="gen">
			<b><xsl:text>Volume: </xsl:text></b>
		</span>
		<xsl:apply-templates/><br />
		<xsl:if test="../issue">
			<xsl:text> </xsl:text>
		</xsl:if>
	</xsl:template>

	<!-- issue -->

	<xsl:template match="issue" mode="front">
		<span class="gen">
			<b><xsl:text>Issue: </xsl:text></b>
		</span>
		<xsl:apply-templates/>
		<br/>
		<xsl:call-template name="nl-1"/>
	</xsl:template>

	<!-- elocation-id -->

	<xsl:template match="elocation-id" mode="front">
		<span class="gen">
			<xsl:text>E-location ID: </xsl:text>
		</span>
		<xsl:apply-templates/>
		<br/>
		<xsl:call-template name="nl-1"/>
	</xsl:template>

	<!-- fpage, lpage -->

	<xsl:template match="fpage" mode="front">
		<span class="gen">
			<b><xsl:text>First Page: </xsl:text></b>
		</span>
		<xsl:apply-templates/><br/>
		<xsl:choose>
			<xsl:when test="../lpage">
				<xsl:text> </xsl:text>
			</xsl:when>
			<xsl:otherwise>
				<br/>
				<xsl:call-template name="nl-1"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<xsl:template match="lpage" mode="front">
		<span class="gen">
			<b><xsl:text>Last Page: </xsl:text></b>
		</span>
		<xsl:apply-templates/>
		<br/>
		<xsl:call-template name="nl-1"/>
	</xsl:template>

	<!-- article-id -->

	<xsl:template match="article-id">
		<xsl:choose>
			<xsl:when test="@pub-id-type='coden'">
				<span class="gen">
					<xsl:text>Coden: </xsl:text>
				</span>
				<xsl:apply-templates/>
			</xsl:when>
			<xsl:when test="@pub-id-type='doi'">
				<span class="gen">
					<b><xsl:text>DOI: </xsl:text></b>
				</span>
				<a target="_blank">
				<xsl:attribute name="href">
				http://dx.doi.org/<xsl:apply-templates/>
				</xsl:attribute><xsl:apply-templates/>
				</a>
			</xsl:when>
			<xsl:when test="@pub-id-type='medline'">
				<span class="gen">
					<xsl:text>Medline Id: </xsl:text>
				</span>
				<xsl:apply-templates/>
			</xsl:when>
			<xsl:when test="@pub-id-type='pii'">
				<span class="gen">
					<xsl:text>Publisher Item Identifier: </xsl:text>
				</span>
				<xsl:apply-templates/>
			</xsl:when>
			<xsl:when test="@pub-id-type='pmid'">
				<span class="gen">
					<b><xsl:text>PMID: </xsl:text></b>
				</span>
				<a target="_blank">
				<xsl:attribute name="href">
				http://www.ncbi.nlm.nih.gov/pubmed/<xsl:apply-templates/>
				</xsl:attribute><xsl:apply-templates/>
				</a>
			</xsl:when>
            <xsl:when test="@pub-id-type='pmcid'">
				<span class="gen">
					<b><xsl:text>PMCID: </xsl:text></b>
				</span>
				<a target="_blank">
				<xsl:attribute name="href">
				http://www.ncbi.nlm.nih.gov/pmc/articles/<xsl:apply-templates/>
				</xsl:attribute><xsl:apply-templates/>
				</a>
			</xsl:when>
			<xsl:when test="@pub-id-type='publisher-id'">
				<span class="gen">
					<b><xsl:text>Publisher Id: </xsl:text></b>
				</span>
				<a>
				<xsl:attribute name="href"><xsl:text>../../../../FULLTEXT/</xsl:text><xsl:apply-templates/>
				</xsl:attribute><xsl:apply-templates/>
				</a>
			</xsl:when>
			<xsl:when test="@pub-id-type='sici'">
				<span class="gen">
					<xsl:text>Serial Item and Contribution Identifier: </xsl:text>
				</span>
				<xsl:apply-templates/>
			</xsl:when>
			<xsl:when test="@pub-id-type='doaj'">
				<span class="gen">
					<xsl:text>Directory of Open Access Journals</xsl:text>
				</span>
				<xsl:apply-templates/>
			</xsl:when>
			<xsl:when test="@pub-id-type='other'">
				<span class="gen">
					<xsl:text>Article Id: </xsl:text>
				</span>
				<xsl:apply-templates/>
			</xsl:when>
			<xsl:otherwise>
				<span class="gen">
					<xsl:text>ID: </xsl:text>
				</span>
				<xsl:apply-templates/>
			</xsl:otherwise>
		</xsl:choose>

		
		<br/>
		<xsl:call-template name="nl-1"/>

	</xsl:template>

	<!-- contract-num, contract-sponsor -->

	<xsl:template match="contract-num | contract-sponsor" mode="front">
		<xsl:choose>
			<xsl:when test="@xlink:href">
				<a>
					<xsl:call-template name="make-href"/>
					<xsl:call-template name="make-id"/>
					<xsl:apply-templates/>
					<br/>
				</a>
			</xsl:when>
			<xsl:otherwise>
				<span class="capture-id">
					<xsl:call-template name="make-id"/>
					<xsl:apply-templates/>
				</span>
				<br/>
			</xsl:otherwise>
		</xsl:choose>
		<xsl:call-template name="nl-1"/>
	</xsl:template>

	<!-- custom-meta-wrap -->
	
	<xsl:template match="custom-meta-wrap">
		<xsl:for-each select="custom-meta">
			<span class="gen">
				<xsl:value-of select="meta-name"/>
				<xsl:text>: </xsl:text>
			</span>
			<xsl:value-of select="meta-value"/>
			<br/>
		</xsl:for-each>
	</xsl:template>
	
	



	<!-- ============================================================= -->
	<!--  36) TITLE-GROUP                                              -->
	<!-- ============================================================= -->

	<!-- title-group -->

	<!-- Appears only in article-meta -->
	<!-- The fn-group, if any, is output in the "back" of the
     HTML page, together with any other fn-group. -->

	<xsl:template match="title-group" mode="front">
		
			<xsl:apply-templates select="article-title" mode="front"/>
			<xsl:apply-templates select="subtitle" mode="front"/>
			<xsl:apply-templates select="trans-title | alt-title" mode="front"/>
		
	</xsl:template>

	<xsl:template match="article-title" mode="front">
		<xsl:apply-templates/>
		<xsl:call-template name="nl-1"/>
	</xsl:template>

	<!-- subtitle runs in with title -->
	<xsl:template match="subtitle" mode="front">
		<xsl:text>: </xsl:text>
		<xsl:apply-templates/>
		<xsl:call-template name="nl-1"/>
	</xsl:template>

	<xsl:template match="trans-title" mode="front">
		<span class="tl-section-level">
			<span class="gen">Translated title: </span>
			<xsl:apply-templates/>
		</span>
		<xsl:call-template name="nl-1"/>
	</xsl:template>

	<xsl:template match="alt-title" mode="front">
		<span class="tl-default">
			<xsl:choose>
				<xsl:when test="@alt-title-type='right-running-head'">
					<span class="gen">Title for RRH: </span>
				</xsl:when>
				<xsl:otherwise>
					<span class="gen">Alternate Title: </span>
				</xsl:otherwise>
			</xsl:choose>

			<xsl:apply-templates/>
		</span>
		<xsl:call-template name="nl-1"/>
	</xsl:template>

	<!-- ============================================================= -->
	<!--  37) PARTS OF CONTRIB                                         -->
	<!-- ============================================================= -->

	<!-- collab -->
	<!-- A mixed-content model; process it as given -->

	<xsl:template match="collab" mode="front">
		<xsl:choose>
			<xsl:when test="@xlink:href">
				<a>
					<xsl:call-template name="make-href"/>
					<xsl:call-template name="make-id"/>
					<xsl:apply-templates/>
				</a>
			</xsl:when>
			<xsl:otherwise>
				<span class="capture-id">
					<xsl:call-template name="make-id"/>
					<xsl:apply-templates/>
				</span>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>


	<!-- name -->
	<!-- uses mode="contrib" within -->

	<xsl:template match="name" mode="front">
		<xsl:apply-templates select="prefix" mode="contrib"/>
		<xsl:apply-templates select="given-names" mode="contrib"/>
		<xsl:apply-templates select="surname" mode="contrib"/>
		<xsl:apply-templates select="suffix" mode="contrib"/>
		<xsl:apply-templates select="../degrees" mode="contrib"/>
		<sup><xsl:apply-templates select="../xref" mode="contrib"/></sup>
	</xsl:template>

	<xsl:template match="prefix | given-names" mode="contrib">
		<xsl:apply-templates/>
		<xsl:text> </xsl:text>
	</xsl:template>

	<xsl:template match="surname" mode="contrib">
		<xsl:apply-templates/>
	</xsl:template>

	<xsl:template match="suffix" mode="contrib">
		<xsl:text>, </xsl:text>
		<xsl:apply-templates/>
	</xsl:template>

	<xsl:template match="degrees" mode="contrib">
		<xsl:text>, </xsl:text>
		<xsl:apply-templates/>
	</xsl:template>

	<!-- the formatting is sometimes in the source XML,
     e.g., <sup><italic>a</italic></sup> -->
	<xsl:template match="xref[@ref-type='author-notes']" mode="contrib">
		<span class="au-label">			
			<a href="#{@rid}">
				<xsl:choose>
					<xsl:when test="child::node()">
						<xsl:apply-templates/>
					</xsl:when>
					<xsl:otherwise>
						<xsl:value-of select="@rid"/>
					</xsl:otherwise>
				</xsl:choose>
			</a>
		</span>
		<xsl:choose>
                        <xsl:when test="following-sibling::xref">
                            <span><xsl:text>, </xsl:text></span>
                        </xsl:when>
						<xsl:otherwise>
							<xsl:text></xsl:text>
                        </xsl:otherwise>
                    </xsl:choose>
	</xsl:template>

	<!-- the formatting is sometimes in the source XML,
     e.g., <sup><italic>a</italic></sup> -->
	<xsl:template match="xref[@ref-type='aff']" mode="contrib">
		<span class="au-label">			
			<a href="#{@rid}">
				<xsl:choose>
					<xsl:when test="child::node()">
						<xsl:apply-templates/>
					</xsl:when>
					<xsl:otherwise>
						<xsl:value-of select="@rid"/>
					</xsl:otherwise>
				</xsl:choose>
			</a>
		</span>
		<xsl:choose>
                        <xsl:when test="following-sibling::xref">
                            <span><xsl:text>, </xsl:text></span>
                        </xsl:when>
						<xsl:otherwise>
							<xsl:text></xsl:text>
                        </xsl:otherwise>
                    </xsl:choose>
	</xsl:template>
	
	<xsl:template match="xref[@ref-type='corresp']" mode="contrib">
		<span class="au-label">			
			<a href="#{@rid}">
				<xsl:choose>
					<xsl:when test="child::node()">
						<xsl:apply-templates/>
					</xsl:when>
					<xsl:otherwise>
						<xsl:value-of select="@rid"/>
					</xsl:otherwise>
				</xsl:choose>
			</a>
		</span>
		<xsl:choose>
                        <xsl:when test="following-sibling::xref">
                            <span><xsl:text>, </xsl:text></span>
                        </xsl:when>
						<xsl:otherwise>
							<xsl:text></xsl:text>
                        </xsl:otherwise>
                    </xsl:choose>
	</xsl:template>
    
    <xsl:template match="xref[@ref-type='fn']" mode="contrib">
		<span class="au-label">			
			<a href="#{@rid}">
				<xsl:choose>
					<xsl:when test="child::node()">
						<xsl:apply-templates/>
					</xsl:when>
					<xsl:otherwise>
						<xsl:value-of select="@rid"/>
					</xsl:otherwise>
				</xsl:choose>
			</a>
		</span>
		<xsl:choose>
                        <xsl:when test="following-sibling::xref">
                            <span><xsl:text>, </xsl:text></span>
                        </xsl:when>
						<xsl:otherwise>
							<xsl:text></xsl:text>
                        </xsl:otherwise>
                    </xsl:choose>
	</xsl:template>

	<!-- author-comment -->
	<!-- optional title, one-or-more paras -->

	<xsl:template match="author-comment | bio" mode="front">

		<xsl:variable name="the-title">
			<xsl:choose>
				<xsl:when test="title">
					<xsl:apply-templates select="title" mode="front"/>
				</xsl:when>
				<xsl:when test="self::author-comment">
					<xsl:text>Author Comment: </xsl:text>
				</xsl:when>
				<xsl:when test="self::bio">
					<xsl:text>Bio: </xsl:text>
				</xsl:when>
				<!-- no logical otherwise -->
			</xsl:choose>
		</xsl:variable>

		<xsl:choose>
			<xsl:when test="@xlink:href">
				<a>
					<xsl:call-template name="make-href"/>
					<xsl:call-template name="make-id"/>
					<xsl:value-of select="$the-title"/>
				</a>
			</xsl:when>
			<xsl:otherwise>
				<xsl:call-template name="make-id"/>
				<xsl:value-of select="$the-title"/>
			</xsl:otherwise>
		</xsl:choose>

		<xsl:apply-templates select="*[not(self::title)]" mode="front"/>
	</xsl:template>

	<xsl:template match="author-comment/title | bio/title" mode="front">
		<xsl:apply-templates/>
	</xsl:template>

	<!-- author-comment/p and bio/p in HTML give too much vertical
     space for the display situation; so we force them to produce
     only breaks. -->
	<xsl:template match="author-comment/p | bio/p" mode="front">
		<xsl:apply-templates/>
		<br/>
		<xsl:call-template name="nl-1"/>
	</xsl:template>

	<!-- parts of contrib: address -->

	<xsl:template match="address" mode="front">
		<span class="gen">
			<xsl:call-template name="make-id"/>
			<xsl:text>Address: </xsl:text>
		</span>
		<xsl:apply-templates mode="front"/>
		<br/>
	</xsl:template>

	<xsl:template match="institution" mode="front">
		<xsl:choose>
			<xsl:when test="@xlink:href">
				<a>
					<xsl:call-template name="make-href"/>
					<xsl:call-template name="make-id"/>
					<xsl:apply-templates/>
				</a>
			</xsl:when>
			<xsl:otherwise>
				<span class="capture-id">
					<xsl:call-template name="make-id"/>
					<xsl:apply-templates/>
				</span>
			</xsl:otherwise>
		</xsl:choose>

		<xsl:if test="following-sibling::*">
			<xsl:text> </xsl:text>
		</xsl:if>
	</xsl:template>

	<xsl:template match="address/*" mode="front">
		<xsl:apply-templates/>
		<xsl:if test="following-sibling::*">
			<xsl:text> </xsl:text>
		</xsl:if>
	</xsl:template>

	<!-- aff -->
	<!-- These affs are inside a contrib element -->
	<xsl:template match="aff" mode="front">
		<span class="gen">
			<xsl:call-template name="make-id"/>
			<xsl:text>Affiliation: </xsl:text>
		</span>

		<xsl:apply-templates/>
		<br/>
		<xsl:call-template name="nl-1"/>
	</xsl:template>

	<!-- aff -->
	<!-- These affs are NOT inside a contrib element -->
	<xsl:template match="aff" mode="aff-outside-contrib">
		<xsl:call-template name="make-id"/>
		<xsl:apply-templates/>
		<br/>
	</xsl:template>



	<!-- on-behalf-of -->

	<xsl:template match="on-behalf-of" mode="front">
		<span class="gen">
			<xsl:text>On behalf of: </xsl:text>
		</span>
		<xsl:apply-templates/>
		<br/>
		<xsl:call-template name="nl-1"/>
	</xsl:template>

	<!-- role -->

	<xsl:template match="role" mode="front">
		<span class="gen">
			<xsl:text>Role: </xsl:text>
		</span>
		<xsl:apply-templates/>
		<br/>
		<xsl:call-template name="nl-1"/>
	</xsl:template>

	<!-- email -->

	<xsl:template match="email" mode="front">
		<xsl:choose>
			<xsl:when test="@xlink:href">
				<a>
					<xsl:call-template name="make-href"/>
					<span class="gen">
						<xsl:text>Email: </xsl:text>
					</span>
					<xsl:apply-templates/>
				</a>
			</xsl:when>
			<xsl:otherwise>
				<span class="gen">
					<xsl:text>Email: </xsl:text>
				</span>
				<xsl:apply-templates/>
			</xsl:otherwise>
		</xsl:choose>
		<xsl:call-template name="nl-1"/>
	</xsl:template>


	<!-- author-notes -->

	<xsl:template match="author-notes" mode="front">
		<span class="capture-id">
			<xsl:call-template name="make-id"/>
			<xsl:apply-templates mode="front"/>
		</span>
	</xsl:template>
	
	

	<!-- author-notes/title -->

	<xsl:template match="author-notes/title" mode="front">
		<b>
			<xsl:apply-templates/>
		</b>
		<br/>
		<xsl:call-template name="nl-1"/>
	</xsl:template>

	<!-- author-notes/corresp -->
	<!-- mixed-content; process it as given -->

	<xsl:template match="author-notes/corresp" mode="front">
		<xsl:call-template name="make-id"/>
		<xsl:if test="not(label)">
			<span class="gen">
				<xsl:call-template name="make-id"/>
				<xsl:text>Correspondence: </xsl:text>
			</span>
		</xsl:if>
		<xsl:apply-templates/>
	</xsl:template>

	<!-- author-notes/fn -->
	<!-- optional label, one or more paras -->
	<!-- unmoded (author-notes only appears in article-meta) -->

	<xsl:template match="author-notes/fn" mode="front">
    	<span class="capture-id">
			<xsl:call-template name="make-id"/>
        </span>
		<xsl:apply-templates/>
		<br/>
		<xsl:call-template name="nl-1"/>
	</xsl:template>

	<!-- author-notes/fn/label -->

	<xsl:template match="author-notes/fn/label">
		<span class="au-label">
			<sup><xsl:apply-templates/></sup><xsl:text> </xsl:text>
		</span>
	</xsl:template>

	<!-- author-notes/fn/p[1] -->

	<xsl:template match="author-notes/fn/p[1]" priority="2">

		<span class="capture-id">
			<xsl:call-template name="make-id"/>

			<xsl:choose>
				<xsl:when test="preceding-sibling::label"/>
				<xsl:when test="parent::fn/@symbol">
					<sup>
						<xsl:value-of select="parent::fn/@symbol"/>
					</sup>
					<xsl:text> </xsl:text>
				</xsl:when>
				<xsl:when test="parent::fn/@fn-type='com'">
					<span class="gen">
						<xsl:text>Communicated by footnote: </xsl:text>
					</span>
				</xsl:when>
				<xsl:when test="parent::fn/@fn-type='con'">
					<span class="gen">
						<xsl:text>Contributed by footnote: </xsl:text>
					</span>
				</xsl:when>
				<xsl:when test="parent::fn/@fn-type='cor'">
					<span class="gen">
						<xsl:text>Correspondence: </xsl:text>
					</span>
				</xsl:when>
				<xsl:when test="parent::fn/@fn-type='financial-disclosure'">
					<span class="gen">
						<xsl:text>Financial Disclosure: </xsl:text>
					</span>
				</xsl:when>
				<xsl:when test="parent::fn/@fn-type">
					<span class="gen">
						<xsl:text>[</xsl:text>
						<xsl:value-of select="parent::fn/@fn-type"/>
						<xsl:text>]</xsl:text>
						<xsl:text> </xsl:text>
					</span>
				</xsl:when>
			</xsl:choose>

			<xsl:apply-templates/>
		</span>
	</xsl:template>

	<!-- author-notes/fn/p processed as ordinary unmoded p-->

	<!-- abstract and trans-abstract are handled entirely
     within the make-front template -->


	<!-- ============================================================= -->
	<!-- BACK (unmoded templates)                                      -->
	<!-- ============================================================= -->

	<!-- ============================================================= -->
	<!--  38. BACK MATTER: ACKNOWLEDGEMENTS                            -->
	<!-- ============================================================= -->

	<xsl:template match="ack">

		<xsl:call-template name="nl-1"/>
		<xsl:if test="position()>1">
			
		</xsl:if>
		<xsl:call-template name="nl-1"/>


		
			<xsl:call-template name="make-id"/>
			<xsl:if test="not(title)">
				<span class="tl-main-part">Acknowledgments</span>
				<xsl:call-template name="nl-1"/>
			</xsl:if>

			<xsl:apply-templates/>

		

	</xsl:template>

	<!-- ============================================================= -->
	<!--  39. BACK-MATTER: APPENDIX                                    -->
	<!-- ============================================================= -->

	<xsl:template match="app">

		<xsl:text>&#xA;</xsl:text>
		<xsl:if test="position()>1">
			
		</xsl:if>
		<xsl:call-template name="nl-1"/>

		<div class="capture-id">
			<xsl:call-template name="make-id"/>
			<xsl:apply-templates/>
			<xsl:call-template name="nl-1"/>
		</div>

	</xsl:template>

	<!-- ============================================================= -->
	<!--  40. BACK-MATTER: FOOTNOTE-GROUP and FN                       -->
	<!-- ============================================================= -->

	<xsl:template match="fn-group">
		<xsl:call-template name="nl-1"/>
		<xsl:if test="position()>1">
			
		</xsl:if>
		<xsl:call-template name="nl-1"/>

		<xsl:apply-templates/>
		<xsl:call-template name="nl-1"/>
	</xsl:template>


	<!-- ============================================================= -->
	<!--  Footnote                                                     -->
	<!-- ============================================================= -->

	<!-- symbol or id is displayed by the first para within the fn     -->

	<xsl:template match="fn">
		<div>
			<xsl:if test="@id">
				<xsl:attribute name="id">
					<xsl:value-of select="@id"/>
				</xsl:attribute>
			</xsl:if>
			<xsl:apply-templates select="p"/>
		</div>
	</xsl:template>


	<!-- ============================================================= -->
	<!--  41. BACK-MATTER: NOTES                                       -->
	<!-- ============================================================= -->

	<xsl:template match="notes">

		<xsl:call-template name="nl-1"/>
		<xsl:if test="position()>1">
			
		</xsl:if>
		<xsl:call-template name="nl-1"/>

		<div class="capture-id">
			<xsl:call-template name="make-id"/>
			<xsl:if test="not(title)">
				<span class="tl-main-part">Notes</span>
				<xsl:call-template name="nl-1"/>
			</xsl:if>

			<xsl:apply-templates/>
			<xsl:call-template name="nl-1"/>
		</div>

	</xsl:template>

	<xsl:template match="note">
		<span class="capture-id">
			<xsl:call-template name="make-id"/>
			<small>
				<xsl:apply-templates/>
			</small>
		</span>
	</xsl:template>

	<!-- ============================================================= -->
	<!--  42. BACK MATTER: GLOSSARY                                    -->
	<!-- ============================================================= -->

	<xsl:template match="glossary">

		<xsl:call-template name="nl-1"/>
		<xsl:if test="position()>1">
			
		</xsl:if>
		<xsl:call-template name="nl-1"/>

		<div class="capture-id">
			<xsl:call-template name="make-id"/>
			<xsl:if test="not(title)">
				<span class="tl-main-part">
					<xsl:call-template name="make-id"/>
					<xsl:text>Glossary</xsl:text>
				</span>
				<xsl:call-template name="nl-1"/>
			</xsl:if>

			<xsl:apply-templates/>
		</div>
		<xsl:call-template name="nl-1"/>

	</xsl:template>

	<xsl:template match="gloss-group">

		<xsl:call-template name="nl-1"/>
		<xsl:if test="not(title)">
			<span class="tl-main-part">Glossary</span>
			<xsl:call-template name="nl-1"/>
		</xsl:if>

		<xsl:apply-templates/>
		<xsl:call-template name="nl-1"/>
	</xsl:template>

	<xsl:template match="def-list">
		<xsl:call-template name="nl-1"/>
		<xsl:call-template name="make-anchor"/>

		<table width="100%" cellpadding="2" class="bm">
			<xsl:call-template name="nl-1"/>

			<xsl:call-template name="table-setup-l-wide"/>
			<xsl:if test="title">
				<tr>
					<th colspan="2" align="left">
						<b><xsl:apply-templates select="title"/></b>
					</th>
				</tr>
			</xsl:if>
			<xsl:if test="term-head|def-head">
				<tr>
					<td valign="top" align="right">
						<i>
							<xsl:apply-templates select="term-head"/>
						</i>
					</td>
					<td valign="top">
						<i>
							<xsl:apply-templates select="def-head"/>
						</i>
					</td>
				</tr>
				<xsl:call-template name="nl-1"/>
			</xsl:if>

			<xsl:apply-templates select="def-item"/>

			<xsl:call-template name="nl-1"/>
			
		</table>
		
		<xsl:if test="def-list">
			<br/>
			<xsl:apply-templates select="def-list"/>
		</xsl:if>
		
		<xsl:call-template name="nl-1"/>

	</xsl:template>


	<xsl:template match="def-item">
		<tr>
			<xsl:call-template name="make-id"/>
			<xsl:call-template name="nl-1"/>
			<xsl:apply-templates/>
		</tr>
		<xsl:call-template name="nl-1"/>
	</xsl:template>

	<xsl:template match="term">
		<td valign="top" align="right">
			<xsl:call-template name="make-id"/>
			<b>
				<xsl:apply-templates/>
			</b>
		</td>
		<xsl:call-template name="nl-1"/>
	</xsl:template>

	<xsl:template match="def">
		<td valign="top">
			<xsl:call-template name="make-id"/>
			<xsl:apply-templates/>
		</td>
		<xsl:call-template name="nl-1"/>
	</xsl:template>


	<!-- ============================================================= -->
	<!--  43. TARGET OF A REFERENCE                                    -->
	<!-- ============================================================= -->

	<xsl:template match="target">
		<a>
			<xsl:call-template name="make-id"/>
			<xsl:apply-templates/>
		</a>
	</xsl:template>


	<!-- ============================================================= -->
	<!--  44. XREFS                                                    -->
	<!-- ============================================================= -->

	<!-- xref for fn, table-fn, or bibr becomes a superior number -->
	<!-- Displays the @rid, not the element content (if any) -->

	<xsl:template
		match="xref[@ref-type='fn']
                  | xref[@ref-type='table-fn']
                  | xref[@ref-type='bibr']">
		<span class="xref">
			<xsl:call-template name="make-id"/>
			
				<!-- if immediately-preceding sibling was an xref, punctuate
           (otherwise assume desired punctuation is in the source).-->
				<xsl:if test="local-name(preceding-sibling::node()[1])='xref'">
					<span class="gen">
						<xsl:text>, </xsl:text>
					</span>
				</xsl:if>
				<a href="#{@rid}">
					<xsl:choose>
						<xsl:when test="@ref-type='bibr'">
							<xsl:attribute name="class">popper</xsl:attribute>
							<xsl:attribute name="data-popbox">
								<xsl:text>r</xsl:text><xsl:value-of select="count(preceding::* | ancestor::*) + 1" /><xsl:text>_s</xsl:text><xsl:value-of select="count(preceding-sibling::sec)+1"/><xsl:text>_p</xsl:text><xsl:value-of select="count(preceding-sibling::p)+1"/><xsl:text>_n</xsl:text><xsl:value-of select="count(preceding-sibling::xref)+1"/><xsl:text>_</xsl:text><xsl:value-of select="/article/front/article-meta/article-id" /><xsl:text>_</xsl:text><xsl:value-of select="@rid"/>
							</xsl:attribute>
						</xsl:when>
					</xsl:choose>
					<xsl:choose>
						<xsl:when test="child::node()">
							<xsl:apply-templates/>
						</xsl:when>
						<xsl:otherwise>
							<xsl:value-of select="@rid"/>
						</xsl:otherwise>
					</xsl:choose>
				</a>
			
		</span>
		<xsl:choose>
			<xsl:when test="@ref-type='bibr'">
				<span class="popbox">
						<xsl:attribute name="id">
							<xsl:text>r</xsl:text><xsl:value-of select="count(preceding::* | ancestor::*) + 1" /><xsl:text>_s</xsl:text><xsl:value-of select="count(preceding-sibling::sec)+1"/><xsl:text>_p</xsl:text><xsl:value-of select="count(preceding-sibling::p)+1"/><xsl:text>_n</xsl:text><xsl:value-of select="count(preceding-sibling::xref)+1"/><xsl:text>_</xsl:text><xsl:value-of select="/article/front/article-meta/article-id" /><xsl:text>_</xsl:text><xsl:value-of select="@rid"/>
						</xsl:attribute>
						<xsl:apply-templates select="/article/back/ref-list" mode="selective">
							<xsl:with-param name="refid" select="@rid"/>
						</xsl:apply-templates>
					</span>
			</xsl:when>
		</xsl:choose>
	</xsl:template>

	<xsl:template match="text()[normalize-space(.)='-']">
		<xsl:choose>
			<!-- if a hyphen is the only thing in a text node
         and it's between two xrefs, we conclude that
         it's expressing a range, and we superscript it -->
			<xsl:when
				test="local-name(following-sibling::node()[1])='xref'
                and local-name(preceding-sibling::node()[1])='xref'">
				<xsl:text>-</xsl:text>
			</xsl:when>
			<xsl:otherwise>
				<xsl:text>-</xsl:text>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<!-- In xref of type fig or of type table,
     the element content is the figure/table number
     and typically part of a sentence,
     so -not- a superior number. -->
	<xsl:template match="xref[@ref-type='fig'] | xref[@ref-type='table']">
		<span class="xref">
			<xsl:call-template name="make-id"/>
			<a href="#{@rid}">
				<xsl:choose>
					<xsl:when test="@ref-type='fig'">
						<xsl:attribute name="class">popper</xsl:attribute>
						<xsl:attribute name="data-popbox">
							<xsl:text>s_</xsl:text><xsl:value-of select="count(preceding-sibling::node())"/><xsl:text>_</xsl:text><xsl:value-of select="/article/front/article-meta/article-id" /><xsl:text>_</xsl:text><xsl:value-of select="@rid"/>
						</xsl:attribute>
					</xsl:when>
				</xsl:choose>
			
				<xsl:choose>
					<!-- if xref not empty -->
					<xsl:when test="child::node()">
						<xsl:apply-templates/>
					</xsl:when>
					<xsl:otherwise>
						<!-- if empty -->
						<xsl:value-of select="@rid"/>
					</xsl:otherwise>
				</xsl:choose>
			</a>
		</span>
		<xsl:choose>
			<xsl:when test="@ref-type='fig'">
				<span class="popbox">
						<xsl:attribute name="id">
							<xsl:text>s_</xsl:text><xsl:value-of select="count(preceding-sibling::node())"/><xsl:text>_</xsl:text><xsl:value-of select="/article/front/article-meta/article-id" /><xsl:text>_</xsl:text><xsl:value-of select="@rid"/>
						</xsl:attribute>
					    <!--
					    <div style="overflow:hidden;">
							<div style="overflow:hidden; width:95%; padding:8px; text-align:justify; background:#ffffff; -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px; border:#cccccc solid thin;">
								-->
								<img width="350">
									<xsl:attribute name="src">
						            	<xsl:text>../../../../../../../../contents/figures/</xsl:text><xsl:value-of select="/article/front/journal-meta/journal-id" /><xsl:text>/</xsl:text><xsl:value-of select="/article/front/article-meta/article-id" /><xsl:text>_</xsl:text><xsl:value-of select="@rid"/><xsl:text>.jpg</xsl:text>
						            </xsl:attribute>
					            </img>
							<!--
							</div>
						</div>-->
					</span>
			</xsl:when>
		</xsl:choose>
	</xsl:template>

	<!-- default: if none of the above ref-types -->
	<xsl:template match="xref">
		<span class="xref">
			<xsl:call-template name="make-id"/>
			<a href="#{@rid}">
				<xsl:choose>
					<xsl:when test="@ref-type='bibr'">
						<xsl:attribute name="class">popper</xsl:attribute>
						<xsl:attribute name="data-popbox">
							<xsl:text>r_</xsl:text><xsl:value-of select="count(preceding-sibling::node())"/><xsl:text>_</xsl:text><xsl:value-of select="/article/front/article-meta/article-id" /><xsl:text>_</xsl:text><xsl:value-of select="@rid"/>
						</xsl:attribute>
					</xsl:when>
					<xsl:when test="@ref-type='fig'">
						<xsl:attribute name="class">popper</xsl:attribute>
						<xsl:attribute name="data-popbox">
							<xsl:value-of select="/article/front/article-meta/article-id" /><xsl:text>_</xsl:text><xsl:value-of select="@rid"/>
						</xsl:attribute>
					</xsl:when>
				</xsl:choose>
				
				<xsl:choose>
					<!-- if xref not empty -->
					<xsl:when test="child::node()">
						<xsl:apply-templates/>
					</xsl:when>
					<xsl:otherwise>
						<!-- if empty -->
						<xsl:value-of select="@rid"/>
					</xsl:otherwise>
				</xsl:choose>
			</a>
		</span>
		<xsl:choose>
			<xsl:when test="@ref-type='bibr'">
				<span class="popbox">
						<xsl:attribute name="id">
							<xsl:text>r_</xsl:text><xsl:value-of select="count(preceding-sibling::node())"/><xsl:text>_</xsl:text><xsl:value-of select="/article/front/article-meta/article-id" /><xsl:text>_</xsl:text><xsl:value-of select="@rid"/>
						</xsl:attribute>
					    <!--
					    <div style="overflow:hidden;">
							<div style="overflow:hidden; width:95%; padding:8px; text-align:justify; background:#ffffff; -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px; border:#cccccc solid thin;">
								
								<img width="350">
									<xsl:attribute name="src">
						            	<xsl:text>../../../../../../../../contents/figures/</xsl:text><xsl:value-of select="/article/front/journal-meta/journal-id" /><xsl:text>/</xsl:text><xsl:value-of select="/article/front/article-meta/article-id" /><xsl:text>_</xsl:text><xsl:value-of select="@rid"/><xsl:text>.jpg</xsl:text>
						            </xsl:attribute>
					            </img>
							
							</div>
						</div>-->
						<xsl:apply-templates select="ref-list" mode="selective">
							<xsl:with-param name="refid" select="@rid"/>
						</xsl:apply-templates>
					</span>
			</xsl:when>
			<xsl:when test="@ref-type='fig'">
				<div class="popbox">
						<xsl:attribute name="id">
							<xsl:value-of select="/article/front/article-meta/article-id" /><xsl:text>_</xsl:text><xsl:value-of select="@rid"/>
						</xsl:attribute>
					    <div style="overflow:hidden;">
							<div style="overflow:hidden; width:95%; padding:8px; text-align:justify; background:#ffffff; -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px; border:#cccccc solid thin;">
								<img width="300">
									<xsl:attribute name="src">
						            	<xsl:text>../../../../../../../../contents/figures/</xsl:text><xsl:value-of select="/article/front/journal-meta/journal-id" /><xsl:text>/</xsl:text><xsl:value-of select="/article/front/article-meta/article-id" /><xsl:text>_</xsl:text><xsl:value-of select="@rid"/><xsl:text>.jpg</xsl:text>
						            </xsl:attribute>
					            </img>
							</div>
						</div>
					</div>
			</xsl:when>
		</xsl:choose>			
	</xsl:template>


	<!-- ============================================================= -->
	<!--  45. EXTERNAL LINKS                                           -->
	<!-- ============================================================= -->

	<!-- xlink:href attribute makes a link -->

	<xsl:template match="ext-link | uri ">
		<xsl:choose>
			<xsl:when test="@xlink:href">
				<a target="xrefwindow" >
					<xsl:call-template name="make-href"/>
					<xsl:call-template name="make-id"/>
					<xsl:apply-templates/>
				</a>
			</xsl:when>
			<xsl:otherwise>
				<span class="capture-id">
					<xsl:call-template name="make-id"/>
					<xsl:apply-templates/>
				</span>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<xsl:template match="ext-link | uri " mode="vancouver">
		<xsl:choose>
			<xsl:when test="@xlink:href">
				<a target="xrefwindow" >
					<xsl:call-template name="make-href"/>
					<xsl:call-template name="make-id"/>
					<xsl:apply-templates/>
				</a>
			</xsl:when>
			<xsl:otherwise>
				<span class="capture-id">
					<xsl:call-template name="make-id"/>
					<xsl:apply-templates/>
				</span>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
    
    <xsl:template match="ext-link | uri " mode="acs">
		<xsl:choose>
			<xsl:when test="@xlink:href">
				<a target="xrefwindow" >
					<xsl:call-template name="make-href"/>
					<xsl:call-template name="make-id"/>
					<xsl:apply-templates/>
				</a>
			</xsl:when>
			<xsl:otherwise>
				<span class="capture-id">
					<xsl:call-template name="make-id"/>
					<xsl:apply-templates/>
				</span>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
    
    <xsl:template match="ext-link | uri " mode="apa">
		<xsl:choose>
			<xsl:when test="@xlink:href">
				<a target="xrefwindow" >
					<xsl:call-template name="make-href"/>
					<xsl:call-template name="make-id"/>
					<xsl:apply-templates/>
				</a>
			</xsl:when>
			<xsl:otherwise>
				<span class="capture-id">
					<xsl:call-template name="make-id"/>
					<xsl:apply-templates/>
				</span>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
    
	<xsl:template match="ext-link | uri " mode="harvard">
		<xsl:choose>
			<xsl:when test="@xlink:href">
				<a target="xrefwindow" >
					<xsl:call-template name="make-href"/>
					<xsl:call-template name="make-id"/>
					<xsl:apply-templates/>
				</a>
			</xsl:when>
			<xsl:otherwise>
				<span class="capture-id">
					<xsl:call-template name="make-id"/>
					<xsl:apply-templates/>
				</span>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<!-- xlink:href attribute makes a link -->

	<xsl:template match="mailto | email">

		<xsl:choose>
			<xsl:when test="@xlink:href">
				<a>
					<xsl:call-template name="make-email"/>
					<xsl:apply-templates/>
				</a>
			</xsl:when>
			<xsl:otherwise>
				<xsl:apply-templates/>
			</xsl:otherwise>
		</xsl:choose>

	</xsl:template>


	<!-- ============================================================= -->
	<!--  46. TITLES: MAIN ARTICLE DIVISIONS                           -->
	<!-- ============================================================= -->

	<!-- main or top-level divisions -->

	<xsl:template
		match="abstract/title | body/sec/title
                   | back/title | app-group/title | app/title
                   | glossary/title | ack/title
                   | ref-list/title | back/notes/title">
		<xsl:call-template name="nl-1"/>
		<span class="tl-main-part">
			<h2>
            <xsl:if test="preceding-sibling::label">
            <xsl:value-of select="../label" /><xsl:text>. </xsl:text></xsl:if>
            <xsl:apply-templates/></h2>
		</span>
		<xsl:call-template name="nl-1"/>
	</xsl:template>


	<!-- ============================================================= -->
	<!--  47. TITLES: FIRST-LEVEL DIVISIONS AND DEFAULT                -->
	<!-- ============================================================= -->

	<!-- first-level divisions and default -->

	<xsl:template
		match="body/sec/sec/title| back/sec/title | abstract/sec/title |ack/sec/title | app/sec/title
                   | boxed-text/title | gloss-group/title | notes/sec/title">
		<xsl:call-template name="nl-1"/>
		<span class="tl-lowest-section">
			<h4><xsl:if test="preceding-sibling::label">
            <xsl:value-of select="../label" /><xsl:text>. </xsl:text></xsl:if><xsl:apply-templates/></h4>
		</span>
		<xsl:call-template name="nl-1"/>
	</xsl:template>
	
	<xsl:template
		match="body/sec/sec/sec/title | back/sec/sec/title | app/sec/sec/title">
		<xsl:call-template name="nl-1"/>
		<span class="tl-lowest-section">
			<h4><xsl:if test="preceding-sibling::label">
            <xsl:value-of select="../label" /><xsl:text>. </xsl:text></xsl:if><xsl:apply-templates/></h4>
		</span>
		<xsl:call-template name="nl-1"/>
	</xsl:template>
	
	<xsl:template
		match="body/sec/sec/sec/sec/title | back/sec/sec/sec/title | app/sec/sec/sec/title">
		<xsl:call-template name="nl-1"/>
		<span class="tl-lowest-section">
			<h5><xsl:if test="preceding-sibling::label">
            <xsl:value-of select="../label" /><xsl:text>. </xsl:text></xsl:if><xsl:apply-templates/></h5>
		</span>
		<xsl:call-template name="nl-1"/>
	</xsl:template>
	
	<xsl:template
		match="body/sec/sec/sec/sec/sec/title | back/sec/sec/sec/sec/title">
		<xsl:call-template name="nl-1"/>
		<span class="tl-lowest-section">
			<h6><xsl:if test="preceding-sibling::label">
            <xsl:value-of select="../label" /><xsl:text>. </xsl:text></xsl:if><xsl:apply-templates/></h6>
		</span>
		<xsl:call-template name="nl-1"/>
	</xsl:template>
	
    <xsl:template match="caption/title">
        <strong><xsl:apply-templates/></strong>
	</xsl:template>
    
	<xsl:template match="list/title">
		<span class="li-title">
			<strong><xsl:apply-templates/></strong>
		</span>
	</xsl:template>
	
	<xsl:template match="def-list/title">
		<strong><xsl:apply-templates/></strong>
	</xsl:template>

	<xsl:template match="kwd-group/title">
		<strong><xsl:apply-templates/>: </strong>
	</xsl:template>

	<!-- default: any other titles found -->


	<xsl:template match="title">
		<xsl:call-template name="nl-1"/>
		<span class="tl-default">
			<xsl:apply-templates/>
		</span>
		<xsl:call-template name="nl-1"/>
	</xsl:template>


	<!-- ============================================================= -->
	<!--  48. TITLES: MAKE-ABSTRACT-TITLE                              -->
	<!-- ============================================================= -->

	<!-- called by template for abstract and trans-abstract -->

	<xsl:template name="words-for-abstract-title">

		<xsl:choose>
			<!-- if there's a title, use it -->
			<xsl:when test="title">
				<xsl:apply-templates select="title"/>
			</xsl:when>

			<!-- abstract with no title -->
			<xsl:when test="self::abstract">
				<span class="gen">
					<h2><xsl:text>Abstract</xsl:text></h2>
				</span>
			</xsl:when>

			<!-- trans-abstract with no title -->
			<xsl:when test="self::trans-abstract">
				<span class="gen">
					<h2><xsl:text>Abstract, Translated</xsl:text></h2>
				</span>
			</xsl:when>
			<!-- there is no logical otherwise -->
		</xsl:choose>

	</xsl:template>


	<!-- ============================================================= -->
	<!--  49. UNMODED DATA ELEMENTS: MISCELLANEOUS                     -->
	<!-- ============================================================= -->

	<!-- epage -->

	<xsl:template match="epage">
		<span class="gen">
			<xsl:text>Electronic Page: </xsl:text>
		</span>
		<xsl:apply-templates/>
		<br/>
	</xsl:template>

	<!-- series -->

	<xsl:template match="series">
		<xsl:text> (</xsl:text>
		<xsl:apply-templates/>
		<xsl:text>).</xsl:text>
	</xsl:template>

	<!-- comment -->

	<xsl:template match="comment">
		<xsl:if test="not(self::node()='.')">
			<xsl:text> </xsl:text>
			<xsl:apply-templates/>
			<xsl:text>. </xsl:text>
		</xsl:if>
	</xsl:template>

	<!-- annotation -->

	<xsl:template match="annotation">
		<br/>
		<xsl:text> [</xsl:text>
		<xsl:apply-templates/>
		<xsl:text>]</xsl:text>
		<br/>
	</xsl:template>


	<!-- permissions -->

	<xsl:template match="permissions">
		<xsl:choose>
			<xsl:when test="copyright-statement">
				<xsl:apply-templates select="copyright-statement"/>
			</xsl:when>
			<xsl:otherwise>
				<xsl:if test="copyright-year">
					<p>
                        <xsl:text>Copyright: </xsl:text>
						<xsl:apply-templates select="copyright-year"/>
						<xsl:apply-templates select="copyright-holder"/>
					</p>
				</xsl:if>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>


	<!-- copyright-statement whether or not part of permissions -->

	<xsl:template match="copyright-statement">
		<p>
			<xsl:apply-templates/>
		</p>
	</xsl:template>
	
	<!-- license whether or not part of permissions -->
	<xsl:template match="license">
		<p>
			<xsl:if test="@license-type">
				<span class="gen">[<xsl:value-of select="@license-type"/>] </span>
			</xsl:if>
			<xsl:apply-templates select="p/* | p/text()"/>
		</p>
	</xsl:template>


	<!-- ============================================================= -->
	<!--  50. UNMODED DATA ELEMENTS: PARTS OF A DATE                   -->
	<!-- ============================================================= -->

	<xsl:template match="day">
		<xsl:apply-templates/>
		<xsl:text>/</xsl:text>
	</xsl:template>

	<xsl:template match="month">
		<xsl:apply-templates/>
		<xsl:text>/</xsl:text>
	</xsl:template>

	<xsl:template match="season">
		<span class="gen">
			<xsl:text>Season: </xsl:text>
		</span>
		<xsl:apply-templates/>
		<xsl:text> </xsl:text>
	</xsl:template>

	<xsl:template match="year">
		<xsl:apply-templates/>
	</xsl:template>

	<xsl:template match="stringdate">
		<span class="gen">
			<xsl:text>Stringdate: </xsl:text>
		</span>
		<xsl:apply-templates/>
	</xsl:template>


	<!-- ============================================================= -->
	<!--  51. UNMODED DATA ELEMENTS: PARTS OF A NAME                   -->
	<!-- ============================================================= -->


	<xsl:template match="name">
		<xsl:variable name="nodetotal" select="count(../*)"/>
		<xsl:variable name="position" select="position()"/>

		<xsl:choose>
			<xsl:when test="given-names">
				<xsl:apply-templates select="surname"/>
				<xsl:text> </xsl:text>
				<xsl:apply-templates select="given-names"/>
				<xsl:if test="suffix">
					<xsl:text> </xsl:text>
					<xsl:apply-templates select="suffix"/>
				</xsl:if>
			</xsl:when>

			<xsl:otherwise>
				<xsl:apply-templates select="surname"/>
			</xsl:otherwise>
		</xsl:choose>

		<xsl:choose>
			<xsl:when test="following-sibling::aff"/>
			<xsl:otherwise>
				<xsl:choose>
					<xsl:when test="$nodetotal=$position">
						<xsl:choose>
							<xsl:when test="parent::person-group/@person-group-type">
								<xsl:choose>
									<xsl:when test="parent::person-group/@person-group-type='author'">
										<xsl:text>. </xsl:text>
									</xsl:when>
									<xsl:otherwise/>
								</xsl:choose>
							</xsl:when>
							<xsl:otherwise>
								<xsl:text>. </xsl:text>
							</xsl:otherwise>
						</xsl:choose>
					</xsl:when>
					<xsl:otherwise>, </xsl:otherwise>
				</xsl:choose>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<xsl:template match="aff">
		<xsl:variable name="nodetotal" select="count(../*)"/>
		<xsl:variable name="position" select="position()"/>

		<span class="capture-id">
			<xsl:call-template name="make-id"/>
			<xsl:text> (</xsl:text>
			<xsl:apply-templates/>
			<xsl:text>)</xsl:text>
		</span>

		<xsl:choose>
			<xsl:when test="$nodetotal=$position">. </xsl:when>
			<xsl:otherwise>, </xsl:otherwise>
		</xsl:choose>

	</xsl:template>


	<xsl:template match="etal">
		<xsl:text>et al.</xsl:text>
		<xsl:choose>

			<xsl:when test="parent::person-group/@person-group-type">
				<xsl:choose>
					<xsl:when test="parent::person-group/@person-group-type='author'">
						<xsl:text> </xsl:text>
					</xsl:when>
					<xsl:otherwise/>
				</xsl:choose>
			</xsl:when>

			<xsl:otherwise>
				<xsl:text> </xsl:text>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>


	<!-- ============================================================= -->
	<!--  CITATION AND NLM-CITATION                                    -->
	<!-- ============================================================= -->


	<!-- NLM Archiving DTD:
       - citation uses mode nscitation.

     NLM Publishing DTD:
       - nlm-citation uses several modes,
         including book, edited-book, conf, and "none".
-->


	<!-- ============================================================= -->
	<!--  52. BACK MATTER: REF-LIST                                    -->
	<!-- ============================================================= -->
	
<xsl:template match="ref-list" mode="selective">
	<xsl:param name="refid" />
    <xsl:for-each select="ref">
    	<xsl:if test="@id = $refid">
    		<xsl:if test="$ref_style='apa'">
	           <xsl:apply-templates select="." mode="apa_selective"/>
			</xsl:if>
	        <xsl:if test="$ref_style='vancouver'">
	           <xsl:apply-templates select="." mode="vancouver_selective"/>
			</xsl:if>
	        <xsl:if test="$ref_style='ieee'">
	           <xsl:apply-templates select="." mode="ieee_selective"/>
	        </xsl:if>
	        <xsl:if test="$ref_style='acs'">
	           <xsl:apply-templates select="." mode="acs_selective"/>
	        </xsl:if>
	        <xsl:if test="$ref_style='harvard'">
	           <xsl:apply-templates select="." mode="harvard_selective"/>
	        </xsl:if>
    	</xsl:if>
    </xsl:for-each>
</xsl:template>
	
	<xsl:template match="ref-list">

		<xsl:if test="position()>1">
			
		</xsl:if>
		
		<xsl:choose>
			<xsl:when test="not(title)">
				<span class="tl-main-part">References</span>
				<xsl:call-template name="nl-1"/>
			</xsl:when>
			<xsl:otherwise>
				<xsl:apply-templates select="title"/>
			</xsl:otherwise>
		</xsl:choose>
		<table width="100%" style="font-size:12px;">
        <xsl:if test="$ref_style='apa'">
           <xsl:apply-templates select="ref" mode="apa"/>
		</xsl:if>
        <xsl:if test="$ref_style='vancouver'">
           <xsl:apply-templates select="ref" mode="vancouver"/>
		</xsl:if>
        <xsl:if test="$ref_style='ieee'">
           <xsl:apply-templates select="ref" mode="ieee"/>
        </xsl:if>
        <xsl:if test="$ref_style='acs'">
           <xsl:apply-templates select="ref" mode="acs"/>
        </xsl:if>
        <xsl:if test="$ref_style='harvard'">
           <xsl:apply-templates select="ref" mode="harvard"/>
        </xsl:if>
        </table>
	</xsl:template>
	
	<xsl:template match="ref-list" mode="old">
		
		<xsl:if test="position()>1">
			
		</xsl:if>
		
		<xsl:choose>
			<xsl:when test="not(title)">
				<span class="tl-main-part">References</span>
				<xsl:call-template name="nl-1"/>
			</xsl:when>
			<xsl:otherwise>
				<xsl:apply-templates select="title"/>
			</xsl:otherwise>
		</xsl:choose>
		<table width="100%" style="font-size:12px;">
        <xsl:if test="@ref-list-type='apa'">
           <xsl:apply-templates select="ref" mode="apa"/>
		</xsl:if>
        <xsl:if test="@ref-list-type='vancouver'">
           <xsl:apply-templates select="ref" mode="vancouver"/>
		</xsl:if>
        <xsl:if test="@ref-list-type='ieee'">
           <xsl:apply-templates select="ref" mode="ieee"/>
        </xsl:if>
        <xsl:if test="@ref-list-type='acs'">
           <xsl:apply-templates select="ref" mode="acs"/>
        </xsl:if>
		
			<xsl:choose>
            
            <!--<xsl:when test="@ref-list-type='apa'">
                <xsl:choose>
                    <xsl:when test="ref/label">
                        <xsl:call-template name="table-setup-l-wide"/>
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:call-template name="table-setup-l-narrow"/>
                    </xsl:otherwise>
                </xsl:choose>
    
               <xsl:apply-templates select="ref" mode="apa"/>
			</xsl:when>-->
            
            
            <xsl:when test="not(@ref-list-type='vancouver') and not(@ref-list-type='apa') and not(@ref-list-type='acs') and not(@ref-list-type='ieee')">
            
            	<xsl:choose>
                    <xsl:when test="ref/label">
                        <xsl:call-template name="table-setup-l-wide"/>
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:call-template name="table-setup-l-narrow"/>
                    </xsl:otherwise>
                </xsl:choose>
    
                <xsl:apply-templates select="*[not(self::title)]"/>
                
           </xsl:when>
            </xsl:choose>
		</table>
		<xsl:call-template name="nl-1"/>
	</xsl:template>
	
	<xsl:template match="ref-list" mode="old">

		<xsl:if test="position()>1">
			
		</xsl:if>

		<xsl:choose>
			<xsl:when test="not(title)">
				<span class="tl-main-part">References</span>
				<xsl:call-template name="nl-1"/>
			</xsl:when>
			<xsl:otherwise>
				<xsl:apply-templates select="title"/>
			</xsl:otherwise>
		</xsl:choose>

		<table width="100%" style="font-size:12px;">

			<xsl:choose>
				<xsl:when test="ref/label">
					<xsl:call-template name="table-setup-l-wide"/>
				</xsl:when>
				<xsl:otherwise>
					<xsl:call-template name="table-setup-l-narrow"/>
				</xsl:otherwise>
			</xsl:choose>

			<xsl:apply-templates select="*[not(self::title)]"/>

		</table>
		<xsl:call-template name="nl-1"/>
	</xsl:template>


	<!-- suppress the ref-list title so it doesn't reappear -->
	<xsl:template match="ref-list/title" mode="nscitation"/>



	<!-- ============================================================= -->
	<!--  53. REF                                                      -->
	<!-- ============================================================= -->

	<!-- If ref/label, ref is a table row;
		If count(ref/citation) > 1, each citation is a table row -->
	
	<xsl:template match="ref" mode="acs_selective">
		<xsl:choose>
			<xsl:when test="count(citation)=0">
				<xsl:apply-templates select="*[not(self::label)]" mode="acs"/>
			</xsl:when>
		</xsl:choose>
	</xsl:template>
    
    <xsl:template match="ref" mode="ieee_selective">
		<xsl:choose>
			<xsl:when test="count(citation)=0">
				<xsl:apply-templates select="*[not(self::label)]" mode="ieee"/>
			</xsl:when>
		</xsl:choose>
	</xsl:template>
    
    <xsl:template match="ref" mode="vancouver_selective">
		<xsl:choose>
			<xsl:when test="count(citation)=0">
				<xsl:apply-templates select="*[not(self::label)]" mode="vancouver"/>
			</xsl:when>
		</xsl:choose>
	</xsl:template>
       
    <xsl:template match="ref" mode="apa_selective">
        	<xsl:for-each select="nlm-citation">
            	<xsl:apply-templates select="." mode="apa"/>
            	<xsl:if test="not(position() = last())">
                	<br />
                </xsl:if>
            </xsl:for-each>
	</xsl:template>
	
	<xsl:template match="ref" mode="harvard_selective">
    	<xsl:for-each select="nlm-citation">
        	<xsl:apply-templates select="." mode="harvard"/>
        	<xsl:if test="not(position() = last())">
            	<br />
            </xsl:if>
        </xsl:for-each>
	</xsl:template>

	<xsl:template match="ref" mode="acs">
		<xsl:choose>
			<xsl:when test="count(citation)=0">
				<tr>
					<td valign="top" align="right">
	                    <a name="{@id}" />
						<xsl:apply-templates select="label"/>
					</td>
					<td valign="top">
						<xsl:apply-templates select="*[not(self::label)]" mode="acs"/>
					</td>
				</tr>	
			</xsl:when>
		</xsl:choose>
	</xsl:template>
    
    <xsl:template match="ref" mode="ieee">
		<xsl:choose>
			<xsl:when test="count(citation)=0">
				<tr>
					<td valign="top" align="right">
	                    <a name="{@id}" />
						<xsl:apply-templates select="label"/>
					</td>
					<td valign="top">
						<xsl:apply-templates select="*[not(self::label)]" mode="ieee"/>
					</td>
				</tr>	
			</xsl:when>
		</xsl:choose>
	</xsl:template>
    
    <xsl:template match="ref" mode="vancouver">
		<xsl:choose>
			<xsl:when test="count(citation)=0">
				<tr>
					<td valign="top" align="right">
                        <a name="{@id}" />
						<xsl:apply-templates select="label"/>
					</td>
					<td valign="top">
						<xsl:apply-templates select="*[not(self::label)]" mode="vancouver"/>
					</td>
				</tr>	
			</xsl:when>
		</xsl:choose>
	</xsl:template>
       
    <xsl:template match="ref" mode="apa">
		<tr>
			<td valign="top">
        	<a name="{@id}" />
        	<xsl:for-each select="nlm-citation">
            	<xsl:apply-templates select="." mode="apa"/>
            	<xsl:if test="not(position() = last())">
                	<br />
                </xsl:if>
            </xsl:for-each>
            </td>
        </tr>
	</xsl:template>
	
	<xsl:template match="ref" mode="harvard">
		<div style="padding-top:10pt;">
        	<a name="{@id}" />
        	<xsl:for-each select="nlm-citation">
            	<xsl:apply-templates select="." mode="harvard"/>
            	<xsl:if test="not(position() = last())">
                	<br />
                </xsl:if>
            </xsl:for-each>
        </div>
	</xsl:template>
	
	<xsl:template match="ref">
		<xsl:choose>
			<xsl:when test="count(citation)=1">
				<tr>
					<td valign="top" align="right">
                    <a name="{@id}" />
						<xsl:apply-templates select="label | citation/label"/>
					</td>
					<td valign="top">
							<xsl:apply-templates select="citation|nlm-citation"/>
					</td>
				</tr>
			</xsl:when>
			<xsl:when test="count(citation)=0">
				<tr>
					<td valign="top" align="right">
                    <a name="{@id}" />
						<xsl:apply-templates select="label"/>
					</td>
					<td valign="top">
						<xsl:apply-templates select="*[not(self::label)]"/>
					</td>
				</tr>
			</xsl:when>
			<xsl:otherwise>
				<xsl:for-each select="citation | nlm-citation">
					<tr>
						<xsl:call-template name="nl-1"/>
						<td valign="top" align="right">
                        	<a name="{@id}" />
							<xsl:if test="parent::ref/label">
								<xsl:apply-templates select="parent::ref/label"/>
							</xsl:if>
							<xsl:apply-templates select="label"/>
						</td>
						<td valign="top">
							<xsl:apply-templates select="."/>
						</td>
					</tr>
				</xsl:for-each>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	
	<!-- becomes content of table cell, column 1-->
	<xsl:template match="ref/label | citation/label">
				<xsl:text>[</xsl:text>
				<xsl:apply-templates/>
				<xsl:text>] </xsl:text>
	</xsl:template>


	<!-- ============================================================= -->
	<!--  54. CITATION (for NLM Archiving DTD)                         -->
	<!-- ============================================================= -->

	<!-- The citation model is mixed-context, so it is processed
     with an apply-templates (as for a paragraph)
       -except-
     if there is no PCDATA (only elements), spacing and punctuation
     also must be supplied = mode nscitation. -->

	<xsl:template match="ref/citation">

		<xsl:choose>
			<!-- if has no significant text content, presume that
           punctuation is not supplied in the source XML
           = transform will supply it. -->
			<xsl:when test="not(text()[normalize-space()])">
				<xsl:apply-templates mode="none"/>
			</xsl:when>

			<!-- mixed-content, processed as paragraph -->
			<xsl:otherwise>
				<xsl:apply-templates mode="nscitation"/>
			</xsl:otherwise>
		</xsl:choose>

	</xsl:template>


	<!-- ============================================================= -->
	<!--  55. NLM-CITATION (for NLM Publishing DTD)                    -->
	<!-- ============================================================= -->

	<!-- The nlm-citation model allows only element content, so
     it takes a pull template and adds punctuation. -->

	<!-- Processing of nlm-citation uses several modes, including
     citation, book, edited-book, conf, inconf, and mode "none".   -->

	<!-- Each citation-type is handled in its own template. -->


	<!-- Book or thesis -->
	<xsl:template
		match="ref/nlm-citation[@citation-type='book']
                   | ref/nlm-citation[@citation-type='thesis']">

		<xsl:variable name="augroupcount" select="count(person-group) + count(collab)"/>

		<xsl:choose>

			<xsl:when
				test="$augroupcount>1 and
                    person-group[@person-group-type!='author'] and
                    article-title ">
				<xsl:apply-templates select="person-group[@person-group-type='author']" mode="book"/>
				<xsl:apply-templates select="collab" mode="book"/>
				<xsl:apply-templates select="article-title" mode="editedbook"/>
				<xsl:text>In: </xsl:text>
				<xsl:apply-templates
					select="person-group[@person-group-type='editor']
                                 | person-group[@person-group-type='allauthors']
                                 | person-group[@person-group-type='translator']
                                 | person-group[@person-group-type='transed'] "
					mode="book"/>
				<xsl:apply-templates select="source" mode="book"/>
				<xsl:apply-templates select="edition" mode="book"/>
				<xsl:apply-templates select="volume" mode="book"/>
				<xsl:apply-templates select="trans-source" mode="book"/>
				<xsl:apply-templates select="publisher-name | publisher-loc" mode="none"/>
				<xsl:apply-templates select="year | month | time-stamp | season | access-date" mode="book"/>
				<xsl:apply-templates select="fpage | lpage" mode="book"/>
			</xsl:when>

			<xsl:when
				test="person-group[@person-group-type='author'] or
                    person-group[@person-group-type='compiler']">
				<xsl:apply-templates
					select="person-group[@person-group-type='author']
                                 | person-group[@person-group-type='compiler']"
					mode="book"/>
				<xsl:apply-templates select="collab" mode="book"/>
				<xsl:apply-templates select="source" mode="book"/>
				<xsl:apply-templates select="edition" mode="book"/>
				<xsl:apply-templates
					select="person-group[@person-group-type='editor']
                                 | person-group[@person-group-type='translator']
                                 | person-group[@person-group-type='transed'] "
					mode="book"/>
				<xsl:apply-templates select="volume" mode="book"/>
				<xsl:apply-templates select="trans-source" mode="book"/>
				<xsl:apply-templates select="publisher-name | publisher-loc" mode="none"/>
				<xsl:apply-templates select="year | month | time-stamp | season | access-date" mode="book"/>
				<xsl:apply-templates select="article-title | fpage | lpage" mode="book"/>
			</xsl:when>

			<xsl:otherwise>
				<xsl:apply-templates
					select="person-group[@person-group-type='editor']
                                 | person-group[@person-group-type='translator']
                                 | person-group[@person-group-type='transed']
                                 | person-group[@person-group-type='guest-editor']"
					mode="book"/>
				<xsl:apply-templates select="collab" mode="book"/>
				<xsl:apply-templates select="source" mode="book"/>
				<xsl:apply-templates select="edition" mode="book"/>
				<xsl:apply-templates select="volume" mode="book"/>
				<xsl:apply-templates select="trans-source" mode="book"/>
				<xsl:apply-templates select="publisher-name | publisher-loc" mode="none"/>
				<xsl:apply-templates select="year | month | time-stamp | season | access-date" mode="book"/>
				<xsl:apply-templates select="article-title | fpage | lpage" mode="book"/>
			</xsl:otherwise>
		</xsl:choose>

		<xsl:call-template name="citation-tag-ends"/>
	</xsl:template>


	<!-- Conference proceedings -->
	<xsl:template match="ref/nlm-citation[@citation-type='confproc']">

		<xsl:variable name="augroupcount" select="count(person-group) + count(collab)"/>

		<xsl:choose>
			<xsl:when test="$augroupcount>1 and person-group[@person-group-type!='author']">
				<xsl:apply-templates select="person-group[@person-group-type='author']" mode="book"/>
				<xsl:apply-templates select="collab"/>
				<xsl:apply-templates select="article-title" mode="inconf"/>
				<xsl:text>In: </xsl:text>
				<xsl:apply-templates
					select="person-group[@person-group-type='editor']
                                 | person-group[@person-group-type='allauthors']
                                 | person-group[@person-group-type='translator']
                                 | person-group[@person-group-type='transed'] "
					mode="book"/>
				<xsl:apply-templates select="source" mode="conf"/>
				<xsl:apply-templates select="conf-name | conf-date | conf-loc" mode="conf"/>
				<xsl:apply-templates select="publisher-loc" mode="none"/>
				<xsl:apply-templates select="publisher-name" mode="none"/>
				<xsl:apply-templates select="year | month | time-stamp | season | access-date" mode="book"/>
				<xsl:apply-templates select="fpage | lpage" mode="book"/>
			</xsl:when>

			<xsl:otherwise>
				<xsl:apply-templates select="person-group" mode="book"/>
				<xsl:apply-templates select="collab" mode="book"/>
				<xsl:apply-templates select="article-title" mode="conf"/>
				<xsl:apply-templates select="source" mode="conf"/>
				<xsl:apply-templates select="conf-name | conf-date | conf-loc" mode="conf"/>
				<xsl:apply-templates select="publisher-loc" mode="none"/>
				<xsl:apply-templates select="publisher-name" mode="none"/>
				<xsl:apply-templates select="year | month | time-stamp | season | access-date" mode="book"/>
				<xsl:apply-templates select="fpage | lpage" mode="book"/>
			</xsl:otherwise>
		</xsl:choose>

		<xsl:call-template name="citation-tag-ends"/>
	</xsl:template>


	<!-- Government and other reports, other, web, and commun -->
	<xsl:template
		match="ref/nlm-citation[@citation-type='gov']
                   | ref/nlm-citation[@citation-type='web']
                   | ref/nlm-citation[@citation-type='commun']
                   | ref/nlm-citation[@citation-type='other']">

		<xsl:apply-templates select="person-group" mode="book"/>

		<xsl:apply-templates select="collab"/>

		<xsl:choose>
			<xsl:when test="publisher-loc | publisher-name">
				<xsl:apply-templates select="source" mode="book"/>
				<xsl:choose>
					<xsl:when test="@citation-type='web'">
						<xsl:apply-templates select="edition" mode="none"/>
					</xsl:when>
					<xsl:otherwise>
						<xsl:apply-templates select="edition"/>
					</xsl:otherwise>
				</xsl:choose>

				<xsl:apply-templates select="publisher-loc" mode="none"/>
				<xsl:apply-templates select="publisher-name" mode="none"/>
				<xsl:apply-templates select="year | month | time-stamp | season | access-date" mode="book"/>
				<xsl:apply-templates select="article-title|gov" mode="none"/>
			</xsl:when>

			<xsl:otherwise>
				<xsl:apply-templates select="article-title|gov" mode="book"/>
				<xsl:apply-templates select="source" mode="book"/>
				<xsl:apply-templates select="edition"/>
				<xsl:apply-templates select="publisher-loc" mode="none"/>
				<xsl:apply-templates select="publisher-name" mode="none"/>
				<xsl:apply-templates select="year | month | time-stamp | season | access-date" mode="book"/>
			</xsl:otherwise>
		</xsl:choose>

		<xsl:apply-templates select="fpage | lpage" mode="book"/>

		<xsl:call-template name="citation-tag-ends"/>

	</xsl:template>


	<!-- Patents  -->
	<xsl:template match="ref/nlm-citation[@citation-type='patent']">

		<xsl:apply-templates select="person-group" mode="book"/>
		<xsl:apply-templates select="collab" mode="book"/>
		<xsl:apply-templates select="article-title | trans-title" mode="none"/>
		<xsl:apply-templates select="source" mode="none"/>
		<xsl:apply-templates select="patent" mode="none"/>
		<xsl:apply-templates select="year | month | time-stamp | season | access-date" mode="book"/>
		<xsl:apply-templates select="fpage | lpage" mode="book"/>

		<xsl:call-template name="citation-tag-ends"/>

	</xsl:template>


	<!-- Discussion  -->
	<xsl:template match="ref/nlm-citation[@citation-type='discussion']">

		<xsl:apply-templates select="person-group" mode="book"/>
		<xsl:apply-templates select="collab"/>
		<xsl:apply-templates select="article-title" mode="editedbook"/>
		<xsl:text>In: </xsl:text>
		<xsl:apply-templates select="source" mode="none"/>

		<xsl:if test="publisher-name | publisher-loc">
			<xsl:text> [</xsl:text>
			<xsl:apply-templates select="publisher-loc" mode="none"/>
			<xsl:value-of select="publisher-name"/>
			<xsl:text>]; </xsl:text>
		</xsl:if>

		<xsl:apply-templates select="year | month | time-stamp | season | access-date" mode="book"/>
		<xsl:apply-templates select="fpage | lpage" mode="book"/>

		<xsl:call-template name="citation-tag-ends"/>
	</xsl:template>


	<!-- If none of the above citation-types applies,
     use mode="none". This generates punctuation. -->
	<!-- (e.g., citation-type="journal"              -->
	
	<xsl:template match="nlm-citation" mode="acs">
        <xsl:apply-templates
			select="*[not(self::annotation) and
                                 not(self::edition) and
                                 not(self::lpage) and
                                 not(self::pub-id) and
                                 not(self::comment)]|text()"
			mode="acs"/>
            <xsl:if test="@citation-type='other' and not(article-title) and not(source) and publisher-name and publisher-loc">
            	<xsl:value-of select="publisher-name"/><xsl:text>: </xsl:text><xsl:value-of select="publisher-loc"/><xsl:text>, </xsl:text>
            </xsl:if>
            <xsl:apply-templates select="comment" mode="acs"/>
            <xsl:if test="pub-id">
            	<br />
                <xsl:apply-templates select="pub-id" mode="acs"/>
            </xsl:if>
		
	</xsl:template>
    
    <xsl:template match="nlm-citation" mode="ieee">
        <xsl:apply-templates
			select="*[not(self::annotation) and
                                 not(self::edition) and
                                 not(self::pub-id) and
                                 not(self::comment)]|text()"
			mode="ieee"/>
            <xsl:if test="@citation-type='other' and not(article-title) and not(source) and publisher-name and publisher-loc">
            	<xsl:value-of select="publisher-name"/><xsl:text>: </xsl:text><xsl:value-of select="publisher-loc"/><xsl:text>, </xsl:text>
            </xsl:if>
            <xsl:apply-templates select="comment" mode="ieee"/>
            <xsl:if test="pub-id">
            	<br />
                <xsl:apply-templates select="pub-id" mode="ieee"/>
            </xsl:if>
		
	</xsl:template>
    
    <xsl:template match="nlm-citation" mode="vancouver">
        <xsl:apply-templates
			select="*[not(self::annotation) and
                                 not(self::edition) and
                                 not(self::lpage) and
                                 not(self::pub-id) and
                                 not(self::comment)]|text()"
			mode="vancouver"/>
			<xsl:apply-templates select="comment" mode="vancouver"/>
            <xsl:if test="pub-id">
            	<br />
                <xsl:apply-templates select="pub-id" mode="vancouver"/>
            </xsl:if>
			<xsl:if test="following-sibling::nlm-citation">
            	<xsl:text>; </xsl:text>
            </xsl:if>
	</xsl:template>
    
    <xsl:template match="nlm-citation" mode="apa">
        <xsl:apply-templates
			select="*[not(self::annotation) and
                                 not(self::edition) and
                                 not(self::lpage) and
                                 not(self::pub-id) and
                                 not(self::comment)]|text()"
			mode="apa"/>
            <xsl:apply-templates select="comment" mode="apa"/>
            <xsl:if test="pub-id">
            	<br />
                <xsl:apply-templates select="pub-id" mode="apa"/>
            </xsl:if>
		
	</xsl:template>
    
    <xsl:template match="nlm-citation" mode="harvard">
        <xsl:apply-templates
			select="*[not(self::annotation) and
                                 not(self::edition) and
                                 not(self::lpage) and
                                 not(self::pub-id) and
                                 not(self::comment)]|text()"
			mode="harvard"/>
            <xsl:apply-templates select="comment" mode="harvard"/>
            <xsl:if test="pub-id">
            	<br />
                <xsl:apply-templates select="pub-id" mode="harvard"/>
            </xsl:if>
		
	</xsl:template>
    
    <xsl:template match="citation" mode="acs">
						<xsl:apply-templates
			select="*[not(self::annotation) and
                                 not(self::edition) and
                                 not(self::lpage) and
                                 not(self::pub-id) and
                                 not(self::comment)]|text()"
			mode="acs"/>
            <xsl:if test="pub-id">
            	<br />
                <xsl:apply-templates select="pub-id" mode="acs"/>
            </xsl:if>
		<xsl:call-template name="citation-tag-ends"/>

	</xsl:template>
    
    <xsl:template match="citation" mode="apa">
						<xsl:apply-templates
			select="*[not(self::annotation) and
                                 not(self::edition) and
                                 not(self::lpage) and
                                 not(self::pub-id) and
                                 not(self::comment)]|text()"
			mode="apa"/>
            <xsl:if test="pub-id">
            	<br />
                <xsl:apply-templates select="pub-id" mode="apa"/>
            </xsl:if>
		<xsl:call-template name="citation-tag-ends"/>

	</xsl:template>
    
    <xsl:template match="citation" mode="harvard">
						<xsl:apply-templates
			select="*[not(self::annotation) and
                                 not(self::edition) and
                                 not(self::lpage) and
                                 not(self::pub-id) and
                                 not(self::comment)]|text()"
			mode="harvard"/>
            <xsl:if test="pub-id">
            	<br />
                <xsl:apply-templates select="pub-id" mode="harvard"/>
            </xsl:if>
		<xsl:call-template name="citation-tag-ends"/>

	</xsl:template>
    
    <xsl:template match="citation" mode="vancouver">
						<xsl:apply-templates
			select="*[not(self::annotation) and
                                 not(self::edition) and
                                 not(self::lpage) and
                                 not(self::pub-id) and
                                 not(self::comment)]|text()"
			mode="vancouver"/>
            <xsl:if test="pub-id">
            	<br />
                <xsl:apply-templates select="pub-id" mode="vancouver"/>
            </xsl:if>
		<xsl:call-template name="citation-tag-ends"/>

	</xsl:template>

	
    <xsl:template match="nlm-citation">
						<xsl:apply-templates
			select="*[not(self::annotation) and
                                 not(self::edition) and
                                 not(self::lpage) and
                                 not(self::pub-id) and
                                 not(self::comment)]|text()"
			mode="none"/>
            <xsl:if test="pub-id">
            	<br />
                <xsl:apply-templates select="pub-id" mode="none"/>
            </xsl:if>
		<xsl:call-template name="citation-tag-ends"/>

	</xsl:template>
    

	<!-- ============================================================= -->
	<!-- person-group, mode=book                                       -->
	<!-- ============================================================= -->

	<xsl:template match="person-group" mode="book">

		<!-- XX needs fix, value is not a nodeset on the when -->
		<!--
  <xsl:choose>

    <xsl:when test="@person-group-type='editor'
                  | @person-group-type='assignee'
                  | @person-group-type='translator'
                  | @person-group-type='transed'
                  | @person-group-type='guest-editor'
                  | @person-group-type='compiler'
                  | @person-group-type='inventor'
                  | @person-group-type='allauthors'">

      <xsl:call-template name="make-persons-in-mode"/>
      <xsl:call-template name="choose-person-type-string"/>
      <xsl:call-template name="choose-person-group-end-punct"/>

    </xsl:when>

    <xsl:otherwise>
      <xsl:apply-templates mode="book"/>
    </xsl:otherwise>

  </xsl:choose>
-->

		<xsl:call-template name="make-persons-in-mode"/>
		<xsl:call-template name="choose-person-type-string"/>
		<xsl:call-template name="choose-person-group-end-punct"/>

	</xsl:template>



	<!-- if given names aren't all-caps, use book mode -->

	<xsl:template name="make-persons-in-mode">

		<xsl:variable name="gnms" select="string(descendant::given-names)"/>

		<xsl:variable name="GNMS"
			select="translate($gnms,
      'abcdefghjiklmnopqrstuvwxyz',
      'ABCDEFGHJIKLMNOPQRSTUVWXYZ')"/>

		<xsl:choose>
			<xsl:when test="$gnms=$GNMS">
				<xsl:apply-templates/>
			</xsl:when>
			<xsl:otherwise>
				<xsl:apply-templates mode="book"/>
			</xsl:otherwise>
		</xsl:choose>

	</xsl:template>


	<xsl:template name="choose-person-type-string">

		<xsl:variable name="person-group-type">
			<xsl:value-of select="@person-group-type"/>
		</xsl:variable>

		<xsl:choose>
			<!-- allauthors is an exception to the usual choice pattern -->
			<xsl:when test="$person-group-type='allauthors'"/>

			<!-- the usual choice pattern: singular or plural? -->
			<xsl:when test="count(name) > 1 or etal ">
				<xsl:text>, </xsl:text>
				<xsl:value-of select="($person-strings[@source=$person-group-type]/@plural)"/>
			</xsl:when>

			<xsl:otherwise>
				<xsl:text>, </xsl:text>
				<xsl:value-of select="($person-strings[@source=$person-group-type]/@singular)"/>
			</xsl:otherwise>
		</xsl:choose>

	</xsl:template>


	<xsl:template name="choose-person-group-end-punct">

		<xsl:choose>
			<!-- compiler is an exception to the usual choice pattern -->
			<xsl:when test="@person-group-type='compiler'">
				<xsl:text>. </xsl:text>
			</xsl:when>

			<!-- the usual choice pattern: semi-colon or period? -->
			<xsl:when test="following-sibling::person-group">
				<xsl:text>; </xsl:text>
			</xsl:when>
			<xsl:otherwise>
				<xsl:text>. </xsl:text>
			</xsl:otherwise>
		</xsl:choose>

	</xsl:template>


	<!-- ============================================================= -->
	<!--  56. Citation subparts (mode "none" separately at end)        -->
	<!-- ============================================================= -->

	<!-- names -->

	<xsl:template match="name" mode="nscitation">
		<xsl:value-of select="surname"/>
		<xsl:text>, </xsl:text>
		<xsl:value-of select="given-names"/>
		<xsl:text>. </xsl:text>
	</xsl:template>


	<xsl:template match="name" mode="book">
		<xsl:variable name="nodetotal" select="count(../*)"/>
		<xsl:variable name="penult" select="count(../*)-1"/>
		<xsl:variable name="position" select="position()"/>

		<xsl:choose>

			<!-- if given-names -->
			<xsl:when test="given-names">
				<xsl:apply-templates select="surname"/>
				<xsl:text>, </xsl:text>
				<xsl:call-template name="firstnames">
					<xsl:with-param name="nodetotal" select="$nodetotal"/>
					<xsl:with-param name="position" select="$position"/>
					<xsl:with-param name="names" select="given-names"/>
					<xsl:with-param name="pgtype">
						<xsl:choose>
							<xsl:when test="parent::person-group[@person-group-type]">
								<xsl:value-of select="parent::person-group/@person-group-type"/>
							</xsl:when>
							<xsl:otherwise>
								<xsl:value-of select="'author'"/>
							</xsl:otherwise>
						</xsl:choose>
					</xsl:with-param>
				</xsl:call-template>

				<xsl:if test="suffix">
					<xsl:text>, </xsl:text>
					<xsl:apply-templates select="suffix"/>
				</xsl:if>
			</xsl:when>

			<!-- if no given-names -->
			<xsl:otherwise>
				<xsl:apply-templates select="surname"/>
			</xsl:otherwise>
		</xsl:choose>

		<xsl:choose>
			<!-- if have aff -->
			<xsl:when test="following-sibling::aff"/>

			<!-- if don't have aff -->
			<xsl:otherwise>
				<xsl:choose>

					<!-- if part of person-group -->
					<xsl:when test="parent::person-group/@person-group-type">
						<xsl:choose>

							<!-- if author -->
							<xsl:when test="parent::person-group/@person-group-type='author'">
								<xsl:choose>
									<xsl:when test="$nodetotal=$position">. </xsl:when>
									<xsl:when test="$penult=$position">
										<xsl:choose>
											<xsl:when test="following-sibling::etal">, </xsl:when>
											<xsl:otherwise>; </xsl:otherwise>
										</xsl:choose>
									</xsl:when>
									<xsl:otherwise>; </xsl:otherwise>
								</xsl:choose>
							</xsl:when>

							<!-- if not author -->
							<xsl:otherwise>
								<xsl:choose>
									<xsl:when test="$nodetotal=$position"/>
									<xsl:when test="$penult=$position">
										<xsl:choose>
											<xsl:when test="following-sibling::etal">, </xsl:when>
											<xsl:otherwise>; </xsl:otherwise>
										</xsl:choose>
									</xsl:when>
									<xsl:otherwise>; </xsl:otherwise>
								</xsl:choose>
							</xsl:otherwise>
						</xsl:choose>
					</xsl:when>

					<!-- if not part of person-group -->
					<xsl:otherwise>
						<xsl:choose>
							<xsl:when test="$nodetotal=$position">. </xsl:when>
							<xsl:when test="$penult=$position">
								<xsl:choose>
									<xsl:when test="following-sibling::etal">, </xsl:when>
									<xsl:otherwise>; </xsl:otherwise>
								</xsl:choose>
							</xsl:when>
							<xsl:otherwise>; </xsl:otherwise>
						</xsl:choose>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:otherwise>

		</xsl:choose>
	</xsl:template>


	<xsl:template match="collab" mode="book">
		<xsl:apply-templates/>
		<xsl:if test="@collab-type='compilers'">
			<xsl:text>, </xsl:text>
			<xsl:value-of select="@collab-type"/>
		</xsl:if>
		<xsl:if test="@collab-type='assignee'">
			<xsl:text>, </xsl:text>
			<xsl:value-of select="@collab-type"/>
		</xsl:if>
		<xsl:text>. </xsl:text>
	</xsl:template>

	<xsl:template match="etal" mode="book">
		<xsl:text>et al.</xsl:text>
		<xsl:choose>
			<xsl:when test="parent::person-group/@person-group-type">
				<xsl:choose>
					<xsl:when test="parent::person-group/@person-group-type='author'">
						<xsl:text> </xsl:text>
					</xsl:when>
					<xsl:otherwise/>
				</xsl:choose>
			</xsl:when>

			<xsl:otherwise>
				<xsl:text> </xsl:text>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<!-- affiliations -->

	<xsl:template match="aff" mode="book">
		<xsl:variable name="nodetotal" select="count(../*)"/>
		<xsl:variable name="position" select="position()"/>

		<xsl:text> (</xsl:text>
		<xsl:apply-templates/>
		<xsl:text>)</xsl:text>

		<xsl:choose>
			<xsl:when test="$nodetotal=$position">. </xsl:when>

			<xsl:otherwise>, </xsl:otherwise>
		</xsl:choose>
	</xsl:template>



	<!-- publication info -->

	<xsl:template match="article-title" mode="nscitation">
		<xsl:apply-templates/>
	</xsl:template>

	<xsl:template match="article-title" mode="book">
		<xsl:apply-templates/>

		<xsl:choose>
			<xsl:when test="../fpage or ../lpage">
				<xsl:text>; </xsl:text>
			</xsl:when>
			<xsl:otherwise>
				<xsl:text>. </xsl:text>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<xsl:template match="article-title" mode="editedbook">
		<xsl:apply-templates/>
		<xsl:text>. </xsl:text>
	</xsl:template>

	<xsl:template match="article-title" mode="conf">
		<xsl:apply-templates/>
		<xsl:choose>
			<xsl:when test="../conf-name">
				<xsl:text>. </xsl:text>
			</xsl:when>
			<xsl:otherwise>
				<xsl:text>; </xsl:text>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<xsl:template match="article-title" mode="inconf">
		<xsl:apply-templates/>
		<xsl:text>. </xsl:text>
	</xsl:template>



	<xsl:template match="source" mode="nscitation">
		<i>
			<xsl:apply-templates/>
		</i>
	</xsl:template>

	<xsl:template match="source" mode="book">
		<xsl:choose>

			<xsl:when test="../trans-source">
				<xsl:apply-templates/>
				<xsl:choose>
					<xsl:when test="../volume | ../edition">
						<xsl:text>. </xsl:text>
					</xsl:when>
					<xsl:otherwise>
						<xsl:text> </xsl:text>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:when>

			<xsl:otherwise>
				<xsl:apply-templates/>
				<xsl:text>. </xsl:text>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<xsl:template match="source" mode="conf">
		<xsl:apply-templates/>
		<xsl:text>; </xsl:text>
	</xsl:template>

	<xsl:template match="trans-source" mode="book">
		<xsl:text> [</xsl:text>
		<xsl:apply-templates/>
		<xsl:text>]. </xsl:text>
	</xsl:template>

	<xsl:template match="volume" mode="nscitation">
		<xsl:text> </xsl:text>
		<xsl:apply-templates/>
	</xsl:template>

	<xsl:template match="volume | edition" mode="book">
		<xsl:apply-templates/>
		<xsl:if test="@collab-type='compilers'">
			<xsl:text>, </xsl:text>
			<xsl:value-of select="@collab-type"/>
		</xsl:if>
		<xsl:if test="@collab-type='assignee'">
			<xsl:text>, </xsl:text>
			<xsl:value-of select="@collab-type"/>
		</xsl:if>
		<xsl:text>. </xsl:text>
	</xsl:template>

	<!-- dates -->

	<xsl:template match="month" mode="nscitation">
		<xsl:apply-templates/>
	</xsl:template>

	<xsl:template match="month" mode="book">
		<xsl:variable name="month" select="."/>
		<xsl:choose>
			<xsl:when test="$month='01' or $month='1' or $month='January'">Jan</xsl:when>
			<xsl:when test="$month='02' or $month='2' or $month='February'">Feb</xsl:when>
			<xsl:when test="$month='03' or $month='3' or $month='March'">Mar</xsl:when>
			<xsl:when test="$month='04' or $month='4' or $month='April'">Apr</xsl:when>
			<xsl:when test="$month='05' or $month='5' or $month='May'">May</xsl:when>
			<xsl:when test="$month='06' or $month='6' or $month='June'">Jun</xsl:when>
			<xsl:when test="$month='07' or $month='7' or $month='July'">Jul</xsl:when>
			<xsl:when test="$month='08' or $month='8' or $month='August'">Aug</xsl:when>
			<xsl:when test="$month='09' or $month='9' or $month='September'">Sep</xsl:when>
			<xsl:when test="$month='10' or $month='October'">Oct</xsl:when>
			<xsl:when test="$month='11' or $month='November'">Nov</xsl:when>
			<xsl:when test="$month='12' or $month='December'">Dec</xsl:when>
			<xsl:otherwise>
				<xsl:value-of select="$month"/>
			</xsl:otherwise>
		</xsl:choose>

		<xsl:if test="../day">
			<xsl:text> </xsl:text>
			<xsl:value-of select="../day"/>
		</xsl:if>

		<xsl:choose>
			<xsl:when test="../time-stamp">
				<xsl:text>, </xsl:text>
				<xsl:value-of select="../time-stamp"/>
				<xsl:text> </xsl:text>
			</xsl:when>
			<xsl:when test="../access-date"/>
			<xsl:otherwise>
				<xsl:text>. </xsl:text>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>


	<xsl:template match="day" mode="nscitation">
		<xsl:apply-templates/>
	</xsl:template>


	<xsl:template match="year" mode="nscitation">
		<xsl:text> </xsl:text>
		<xsl:apply-templates/>
	</xsl:template>

	<xsl:template match="year" mode="book">
		<xsl:choose>
			<xsl:when test="../month or ../season or ../access-date">
				<xsl:apply-templates/>
				<xsl:text> </xsl:text>
			</xsl:when>
			<xsl:otherwise>
				<xsl:apply-templates/>
				<xsl:text>. </xsl:text>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>



	<xsl:template match="time-stamp" mode="nscitation">
		<xsl:apply-templates/>
	</xsl:template>

	<xsl:template match="time-stamp" mode="book"/>


	<xsl:template match="access-date" mode="nscitation">
		<xsl:apply-templates/>
	</xsl:template>

	<xsl:template match="access-date" mode="book">
		<xsl:text> [</xsl:text>
		<xsl:apply-templates/>
		<xsl:text>]. </xsl:text>
	</xsl:template>



	<xsl:template match="season" mode="book">
		<xsl:apply-templates/>
		<xsl:if test="@collab-type='compilers'">
			<xsl:text>, </xsl:text>
			<xsl:value-of select="@collab-type"/>
		</xsl:if>
		<xsl:if test="@collab-type='assignee'">
			<xsl:text>, </xsl:text>
			<xsl:value-of select="@collab-type"/>
		</xsl:if>
		<xsl:text>. </xsl:text>
	</xsl:template>



	<!-- pages -->

	<xsl:template match="fpage" mode="nscitation">
		<xsl:apply-templates/>
	</xsl:template>

	<xsl:template match="fpage" mode="book">
		<xsl:choose>
        <xsl:when test="../lpage">
	        <xsl:text>pp. </xsl:text>
        </xsl:when>
        <xsl:when test="not(../lpage)">
        	<xsl:text>p. </xsl:text>
        </xsl:when>
        </xsl:choose>
		<xsl:apply-templates/>

		<xsl:if test="../lpage">
			<xsl:text>.</xsl:text>
		</xsl:if>

	</xsl:template>


	<xsl:template match="lpage" mode="book">
		<xsl:choose>
			<xsl:when test="../fpage">
				<xsl:text>-</xsl:text>
				<xsl:apply-templates/>
				<xsl:text>.</xsl:text>
			</xsl:when>
			<xsl:otherwise>
				<xsl:apply-templates/>
				<xsl:text> p.</xsl:text>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<xsl:template match="lpage" mode="nscitation">
		<xsl:apply-templates/>
	</xsl:template>

	<!-- misc stuff -->

	<xsl:template match="pub-id" mode="nscitation">
		<xsl:text> [</xsl:text>
		<xsl:value-of select="@pub-id-type"/>
		<xsl:text>: </xsl:text>
		<xsl:apply-templates/>
		<xsl:text>]</xsl:text>
	</xsl:template>

	<xsl:template match="annotation" mode="nscitation">
		<blockquote>
			<xsl:apply-templates/>
		</blockquote>
	</xsl:template>

	<xsl:template match="comment" mode="nscitation">
		<xsl:if test="not(self::node()='.')">
			<br/>
			<small>
				<xsl:apply-templates/>
			</small>
		</xsl:if>
	</xsl:template>

	<xsl:template match="conf-name | conf-date" mode="conf">
		<xsl:apply-templates/>
		<xsl:text>; </xsl:text>
	</xsl:template>

	<xsl:template match="conf-loc" mode="conf">
		<xsl:apply-templates/>
		<xsl:text>. </xsl:text>
	</xsl:template>


	<!-- All formatting elements in citations processed normally -->
	<xsl:template match="bold | italic | monospace | overline | sc | strike | sub |sup | underline" mode="nscitation">
		<xsl:apply-templates select="."/>
	</xsl:template>
	
	<xsl:template match="bold | italic | monospace | overline | sc | strike | sub |sup | underline" mode="none">
		<xsl:apply-templates select="."/>
	</xsl:template>
	

	<!-- ============================================================= -->
	<!--  "firstnames"                                                 -->
	<!-- ============================================================= -->

	<!-- called by match="name" in book mode,
     as part of citation handling
     when given-names is not all-caps -->

	<xsl:template name="firstnames">
		<xsl:param name="nodetotal"/>
		<xsl:param name="position"/>
		<xsl:param name="names"/>
		<xsl:param name="pgtype"/>

		<xsl:variable name="length" select="string-length($names)-1"/>
		<xsl:variable name="gnm" select="substring($names,$length,2)"/>
		<xsl:variable name="GNM">
			<xsl:call-template name="capitalize">
				<xsl:with-param name="str" select="substring($names,$length,2)"/>
			</xsl:call-template>
		</xsl:variable>

		<!--
<xsl:text>Value of $names = [</xsl:text><xsl:value-of select="$names"/><xsl:text>]</xsl:text>
<xsl:text>Value of $length = [</xsl:text><xsl:value-of select="$length"/><xsl:text>]</xsl:text>
<xsl:text>Value of $gnm = [</xsl:text><xsl:value-of select="$gnm"/><xsl:text>]</xsl:text>
<xsl:text>Value of $GNM = [</xsl:text><xsl:value-of select="$GNM"/><xsl:text>]</xsl:text>
-->

		<xsl:if test="$names">
			<xsl:choose>

				<xsl:when test="$gnm=$GNM">
					<xsl:apply-templates select="$names"/>
					<xsl:choose>
						<xsl:when test="$nodetotal!=$position">
							<xsl:text>.</xsl:text>
						</xsl:when>
						<xsl:when test="$pgtype!='author'">
							<xsl:text>.</xsl:text>
						</xsl:when>
					</xsl:choose>
				</xsl:when>

				<xsl:otherwise>
					<xsl:apply-templates select="$names"/>
				</xsl:otherwise>

			</xsl:choose>
		</xsl:if>

	</xsl:template>



	<!-- ============================================================= -->
	<!-- mode=none                                                     -->
	<!-- ============================================================= -->

	<!-- This mode assumes no punctuation is provided in the XML.
     It is used, among other things, for the citation/ref
     when there is no significant text node inside the ref.        -->

	<xsl:template match="name" mode="none">
		<xsl:value-of select="surname"/>
		<xsl:text>, </xsl:text>
		<xsl:value-of select="given-names"/>
		<xsl:text>. </xsl:text>
	</xsl:template>

	<xsl:template match="article-title" mode="none">
		<xsl:apply-templates/>
		<xsl:text>, </xsl:text>
		
		<xsl:if test="../trans-title">
			<xsl:text>. </xsl:text>
		</xsl:if>
	</xsl:template>
    
    <xsl:template match="article-title" mode="acs">
		<xsl:choose>
            <xsl:when test="../@citation-type='thesis'">
                <em>
                    <xsl:apply-templates/>
                    <xsl:text>.</xsl:text>
                </em>
            </xsl:when>
            <xsl:when test="../@citation-type='confpaper'">
                <em>
                    <xsl:apply-templates/>
                    <xsl:text>.</xsl:text>
                </em>
            </xsl:when>
            <xsl:otherwise>
                <xsl:apply-templates/>
            </xsl:otherwise>
        </xsl:choose>
		<xsl:text> </xsl:text>
		
		<xsl:if test="../trans-title">
			<xsl:text>. </xsl:text>
		</xsl:if>
	</xsl:template>
    
    <xsl:template match="article-title" mode="ieee">
    	<xsl:variable name="edt"><xsl:value-of select="count(../person-group[@person-group-type='editor']/name)"/></xsl:variable>
		<xsl:choose>
            <xsl:when test="../@citation-type='thesis' or ../@citation-type='patent'">
                <em><xsl:text>"</xsl:text>
                <xsl:choose>
                    <xsl:when test="substring(.,string-length(.),1)='.'">
                        <xsl:value-of select="substring(.,1,string-length(.)-1)"/>
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:apply-templates/>
                    </xsl:otherwise>
                </xsl:choose>
                <xsl:text>"</xsl:text></em>
                <xsl:text>, </xsl:text>
            </xsl:when>
            <xsl:otherwise>
            	<xsl:text>"</xsl:text>
                <xsl:choose>
                    <xsl:when test="substring(.,string-length(.),1)='.'">
                        <xsl:value-of select="substring(.,1,string-length(.)-1)"/>
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:apply-templates/>
                    </xsl:otherwise>
                </xsl:choose>
                <xsl:text>", </xsl:text>
            </xsl:otherwise>
        </xsl:choose>
        <xsl:if test="../@citation-type='book' and ../source">
            <xsl:text>In: </xsl:text>
        </xsl:if>
        <xsl:if test="../person-group/@person-group-type='author'">
        <xsl:if test="../person-group/@person-group-type='editor'">
        	
            <xsl:for-each select="../person-group/name">
        		<xsl:if test="../@person-group-type='editor'">
                <xsl:if test="position() = last() and not(position() = 1) and $edt &gt; 1">
                    <xsl:text> and </xsl:text>
                </xsl:if>
                <xsl:value-of select="given-names"/><xsl:text> </xsl:text>
                <xsl:value-of select="surname"/>
                <xsl:if test="suffix">
                    <xsl:text> </xsl:text><xsl:value-of select="suffix"/>
                </xsl:if>
                <xsl:text>, </xsl:text>
                </xsl:if>
            </xsl:for-each>
            <xsl:choose>
            <xsl:when test="not($edt = 1)"><xsl:text>Eds., </xsl:text></xsl:when>
            <xsl:otherwise><xsl:text>Ed., </xsl:text></xsl:otherwise>
           	</xsl:choose>
            
        </xsl:if>
        </xsl:if>
	</xsl:template>
    
    <xsl:template match="article-title" mode="apa">
    	<xsl:variable name="edt"><xsl:value-of select="count(../person-group[@person-group-type='editor']/name)"/></xsl:variable>
		<xsl:apply-templates/>
		<xsl:text> </xsl:text>
		
		<xsl:if test="../trans-title">
			<xsl:text>. </xsl:text>
		</xsl:if>
        <xsl:if test="../person-group/@person-group-type='author'">
        <xsl:if test="../person-group/@person-group-type='editor'">
        	<xsl:text>In: </xsl:text>
            <xsl:for-each select="../person-group/name">
        		<xsl:if test="../@person-group-type='editor'">
                <xsl:value-of select="surname"/><xsl:text>, </xsl:text>
                <xsl:value-of select="given-names"/>
                <xsl:if test="suffix">
                    <xsl:text>, </xsl:text><xsl:value-of select="suffix"/>
                </xsl:if>
                <xsl:text>, </xsl:text>
                </xsl:if>
            </xsl:for-each>
            <xsl:choose>
            <xsl:when test="not($edt = 1)"><xsl:text>(Eds.), </xsl:text></xsl:when>
            <xsl:otherwise><xsl:text>(Ed.), </xsl:text></xsl:otherwise>
           	</xsl:choose>
            
        </xsl:if>
        </xsl:if>
	</xsl:template>
    
    <xsl:template match="article-title" mode="harvard">
    	<xsl:variable name="edt"><xsl:value-of select="count(../person-group[@person-group-type='editor']/name)"/></xsl:variable>
		<xsl:apply-templates/>
		<xsl:text> </xsl:text>
		
		<xsl:if test="../trans-title">
			<xsl:text>. </xsl:text>
		</xsl:if>
        <xsl:if test="../person-group/@person-group-type='author'">
        <xsl:if test="../person-group/@person-group-type='editor'">
        	<xsl:text>In: </xsl:text>
            <xsl:for-each select="../person-group/name">
        		<xsl:if test="../@person-group-type='editor'">
                <xsl:value-of select="surname"/><xsl:text>, </xsl:text>
                <xsl:value-of select="given-names"/>
                <xsl:if test="suffix">
                    <xsl:text>, </xsl:text><xsl:value-of select="suffix"/>
                </xsl:if>
                <xsl:text>, </xsl:text>
                </xsl:if>
            </xsl:for-each>
            <xsl:choose>
            <xsl:when test="not($edt = 1)"><xsl:text>(Eds.), </xsl:text></xsl:when>
            <xsl:otherwise><xsl:text>(Ed.), </xsl:text></xsl:otherwise>
           	</xsl:choose>
            
        </xsl:if>
        </xsl:if>
	</xsl:template>
    
    <xsl:template match="article-title" mode="vancouver">
    	<xsl:variable name="edt"><xsl:value-of select="count(../person-group[@person-group-type='editor']/name)"/></xsl:variable>
        <xsl:variable name="nvr">
        	<xsl:choose>
                <xsl:when test="$edt &gt; 6">
                    <xsl:text>3</xsl:text>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:value-of select="$edt"/>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:variable>
		<xsl:apply-templates mode="vancouver"/>
		<xsl:choose>
            <xsl:when test="substring(.,string-length(.),1) = '?'">
                <xsl:text> </xsl:text>
            </xsl:when>
            <xsl:otherwise>
            	<xsl:text> </xsl:text>
            </xsl:otherwise>
        </xsl:choose>
		<xsl:if test="../trans-title">
			<xsl:text>. </xsl:text>
		</xsl:if>
        <xsl:if test="../person-group/@person-group-type='author'">
        <xsl:if test="../person-group/@person-group-type='editor'">
        	<xsl:text>In: </xsl:text>
            <xsl:for-each select="../person-group[@person-group-type='editor']/name">
            	<xsl:if test="position() &lt;= $nvr">
                    <xsl:if test="../@person-group-type='editor'">
                        <xsl:value-of select="surname"/><xsl:text> </xsl:text>
                        <xsl:value-of select="translate(given-names,'.','')"/>
                        <xsl:if test="suffix">
                            <xsl:text>, </xsl:text><xsl:value-of select="suffix"/>
                        </xsl:if>
                        <xsl:text>, </xsl:text>
                    </xsl:if>
                </xsl:if>
            </xsl:for-each>
            <xsl:choose>
            <xsl:when test="count(../person-group[@person-group-type='editor']/name) &gt; 6 ">
                <em><xsl:text>et al., </xsl:text></em><xsl:text>Eds., </xsl:text>
            </xsl:when>
            <xsl:when test="not($edt = 1 and $edt &lt; 7)"><xsl:text>Eds. </xsl:text></xsl:when>
            <xsl:otherwise><xsl:text>Ed. </xsl:text></xsl:otherwise>
           	</xsl:choose>
            
        </xsl:if>
        </xsl:if>
		<xsl:if test="$edt &lt; 1 and ../@citation-type='book'">
            	<xsl:text>In: </xsl:text>
            </xsl:if>        
	</xsl:template>



	<xsl:template match="volume" mode="none">
		<xsl:apply-templates/>
		
	</xsl:template>
	
    <xsl:template match="volume" mode="acs">
	    <xsl:if test="not(../@citation-type='book')">
			<em><xsl:apply-templates/></em>
		</xsl:if>
	</xsl:template>
    
    <xsl:template match="volume" mode="ieee"/>
    
    <xsl:template match="edition" mode="ieee-explicit">
        <xsl:apply-templates/>
        <xsl:choose>
            <xsl:when test="../@citation-type='book'">
            	<xsl:text> </xsl:text>
            </xsl:when>
        </xsl:choose>
	</xsl:template>
    
    <xsl:template match="volume" mode="ieee-explicit">
	    <xsl:text>vol. </xsl:text>
			<xsl:apply-templates/>
        <xsl:choose>
            <xsl:when test="../@citation-type='book'">
            	<xsl:text>. </xsl:text>
            </xsl:when>
            <xsl:otherwise>
                <xsl:text>, </xsl:text>
            </xsl:otherwise>
        </xsl:choose>
	</xsl:template>
    
    <xsl:template match="volume" mode="apa">
		<xsl:if test="not(../@citation-type='book')">
        <em><xsl:apply-templates/></em>
		</xsl:if>
	</xsl:template>
    
    <xsl:template match="volume" mode="harvard">
		<xsl:if test="not(../@citation-type='book')">
        <xsl:apply-templates/>
        <xsl:if test="../issue">
        	<xsl:text>(</xsl:text>
            	<xsl:value-of select="../issue" />
            <xsl:text>)</xsl:text>
        </xsl:if>
        
		</xsl:if>
	</xsl:template>
    
    <xsl:template match="volume" mode="vancouver">
		<xsl:if test="not(../@citation-type='book')">
			<xsl:apply-templates/>
		</xsl:if>
	</xsl:template>
    
	<xsl:template match="edition" mode="none">
		<xsl:apply-templates/>
		<xsl:text>. </xsl:text>
	</xsl:template>
    
    <xsl:template match="edition" mode="acs">
		<xsl:if test="not(../@citation-type='book')">
        <xsl:apply-templates/>
		<xsl:text>. </xsl:text>
        </xsl:if>
	</xsl:template>
    
    <xsl:template match="edition" mode="apa">
		<xsl:if test="not(../@citation-type='book')">
        <xsl:apply-templates/>
		<xsl:text>.</xsl:text>
        </xsl:if>
	</xsl:template>
    
    <xsl:template match="edition" mode="harvard">
        <xsl:apply-templates/>
	</xsl:template>
    
    <xsl:template match="edition" mode="apa-explicit">
        <xsl:apply-templates/>
	</xsl:template>
    
    <xsl:template match="edition" mode="acs-explicit">
        <xsl:apply-templates/>
	</xsl:template>
    
    <xsl:template match="edition" mode="vancouver">
		<xsl:apply-templates/>
		<xsl:text>.</xsl:text>
	</xsl:template>

	<xsl:template match="supplement" mode="none">
		<xsl:text> </xsl:text>
		<xsl:apply-templates/>
	</xsl:template>
	
    <xsl:template match="supplement" mode="acs">
		<xsl:text>(</xsl:text>
		<xsl:apply-templates/>
		<xsl:text>)</xsl:text>
	</xsl:template>
    
    <xsl:template match="supplement" mode="ieee"/>

    
    <xsl:template match="supplement" mode="ieee-explicit">
		<xsl:text>suppl. </xsl:text>
		<xsl:apply-templates/>
        <xsl:text>, </xsl:text>
	</xsl:template>
    
    <xsl:template match="supplement" mode="apa">
		<xsl:text> (</xsl:text>
		<xsl:apply-templates/>
        <xsl:text>)</xsl:text>
        <xsl:if test="not(../volume)">
        	<xsl:text>, </xsl:text>
        </xsl:if>
	</xsl:template>
    
    <xsl:template match="supplement" mode="harvard">
		<xsl:text> (</xsl:text>
		<xsl:apply-templates/>
        <xsl:text>)</xsl:text>
        <xsl:if test="not(../volume)">
        	<xsl:text>, </xsl:text>
        </xsl:if>
	</xsl:template>
    
    <xsl:template match="supplement" mode="vancouver">
		<xsl:if test="not(../@citation-type='book')">
        <xsl:text>(</xsl:text>
		<xsl:apply-templates/>
        <xsl:text>)</xsl:text>
        <xsl:if test="not(../fpage or ../lpage or ../comment)">
        	<xsl:text>.</xsl:text>
        </xsl:if>
        </xsl:if>
	</xsl:template>
    
	<xsl:template match="issue" mode="none">
		<xsl:text>(</xsl:text>
		<xsl:apply-templates/>
		<xsl:text>)</xsl:text>
	</xsl:template>
    
    <xsl:template match="issue" mode="acs">
		<xsl:text>(</xsl:text>
		<xsl:apply-templates/>
		<xsl:text>)</xsl:text>
	</xsl:template>
    
    <xsl:template match="issue" mode="ieee"/>
    
    <xsl:template match="issue" mode="ieee-explicit">
		<xsl:text>no. </xsl:text>
		<xsl:apply-templates/>
		<xsl:text>, </xsl:text>
	</xsl:template>
    
    <xsl:template match="issue" mode="apa">
		<xsl:text>(</xsl:text>
		<xsl:apply-templates/>
		<xsl:text>)</xsl:text>
        <xsl:if test="not(../volume)">
        	<xsl:text>, </xsl:text>
        </xsl:if>
	</xsl:template>
    
    <xsl:template match="issue" mode="harvard" />
    
    <xsl:template match="issue" mode="vancouver">
		<xsl:text>(</xsl:text>
		<xsl:apply-templates/>
		<xsl:text>)</xsl:text>
        <xsl:if test="not(../volume)">
        	<xsl:text>: </xsl:text>
        </xsl:if>
	</xsl:template>

	<xsl:template match="publisher-loc" mode="none">
		<xsl:apply-templates/>
		<xsl:text>: </xsl:text>
	</xsl:template>
    
    
    
    <xsl:template match="publisher-loc" mode="apa">
		<xsl:if test="../@citation-type='book'">
        	<xsl:if test="../edition or ../volume or ../fpage or ../lpage">
            <xsl:text>(</xsl:text>
            	<xsl:if test="../edition">
                	<xsl:apply-templates select="../edition" mode="apa-explicit"/><xsl:text>.</xsl:text>
                </xsl:if>
                <xsl:if test="(../edition and ../volume) or (../edition and ../fpage)">
                	<xsl:text>, </xsl:text>
                </xsl:if>
            	<xsl:if test="../volume">
                	<xsl:text>Vol. </xsl:text><xsl:value-of select="../volume"/>
                </xsl:if>
                <xsl:if test="../volume and ../fpage">
                	<xsl:text>, </xsl:text>
                </xsl:if>
                <xsl:choose>
                	<xsl:when test="../fpage and ../lpage">
                    	<xsl:text>pp. </xsl:text><xsl:value-of select="../fpage"/><xsl:text>-</xsl:text><xsl:value-of select="../lpage"/>
                    </xsl:when>
                    <xsl:when test="../fpage and not(../lpage)">
                    	<xsl:text>p. </xsl:text><xsl:value-of select="../fpage"/>
                    </xsl:when>
                </xsl:choose>
            <xsl:text>). </xsl:text>
            </xsl:if>
        </xsl:if>
        <xsl:apply-templates/>
		<xsl:choose>
            <xsl:when test="../publisher-name">
                <xsl:text>: </xsl:text>
            </xsl:when>
            <xsl:when test="not(../publisher-name)">
                <xsl:text>.</xsl:text>
            </xsl:when>
        </xsl:choose>
	</xsl:template>
	
    
    
	<xsl:template match="publisher-name" mode="none">
		<xsl:apply-templates/>
		<xsl:text>; </xsl:text>
	</xsl:template>
    
    <xsl:template match="publisher-loc" mode="harvard" />
     
    <xsl:template match="publisher-loc" mode="harvard-explicit">
    	<xsl:apply-templates/>
    </xsl:template>
    
    <xsl:template match="publisher-name" mode="apa">
		<xsl:apply-templates/>
		<xsl:text>.</xsl:text>
	</xsl:template>
	
    <xsl:template match="publisher-name" mode="harvard">
		<xsl:apply-templates/>
        <xsl:if test="../publisher-loc">
        	<xsl:text>, </xsl:text>
        	<xsl:apply-templates select="../publisher-loc" mode="harvard-explicit" />
        </xsl:if>
        <xsl:choose>
        <xsl:when test="../fpage">
        	<xsl:text> </xsl:text>
        </xsl:when>
        <xsl:otherwise>
			<xsl:text>.</xsl:text>
        </xsl:otherwise>
        </xsl:choose>
	</xsl:template>
    
	<xsl:template match="person-group" mode="none">
		<xsl:variable name="gnms" select="string(descendant::given-names)"/>
		<xsl:variable name="GNMS">
			<xsl:call-template name="capitalize">
				<xsl:with-param name="str" select="$gnms"/>
			</xsl:call-template>
		</xsl:variable>

		<xsl:choose>
			<xsl:when test="$gnms=$GNMS">
				<xsl:apply-templates/>
			</xsl:when>

			<xsl:otherwise>
				<xsl:apply-templates select="node()" mode="book"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<xsl:template match="person-group" mode="acs">
		<xsl:if test="@person-group-type='author'">
        <xsl:for-each select="name">
        	<xsl:value-of select="surname"/><xsl:text>, </xsl:text>
            <xsl:value-of select="given-names"/>
            <xsl:if test="suffix">
            	<xsl:text>, </xsl:text><xsl:value-of select="suffix"/>
            </xsl:if>
            <xsl:choose>
                <xsl:when test="following-sibling::name">
                    <xsl:text>; </xsl:text>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:if test="../@person-group-type='inventor'">
                        <xsl:text>, inventors;</xsl:text>
                    </xsl:if>
                    <xsl:text> </xsl:text>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:for-each>
        </xsl:if>
	</xsl:template>
    
    <xsl:template match="person-group" mode="ieee">
    	<xsl:variable name="edt"><xsl:value-of select="count(../person-group[@person-group-type='editor']/name)"/></xsl:variable>
		<xsl:if test="@person-group-type='author'">
        <xsl:for-each select="name">
        	<xsl:if test="position() = last() and not(position() = 1)">
            	<xsl:text> and </xsl:text>
            </xsl:if>
            <xsl:value-of select="given-names"/><xsl:text> </xsl:text>
            <xsl:value-of select="surname"/>
            <xsl:if test="suffix">
            	<xsl:text> </xsl:text><xsl:value-of select="suffix"/>
            </xsl:if>
            <xsl:text>, </xsl:text>
        </xsl:for-each>
        </xsl:if>
        <xsl:if test="not(../person-group/@person-group-type='author') and not(../article-title)">
        <xsl:if test="../person-group/@person-group-type='editor'">
            <xsl:for-each select="../person-group/name">
        		<xsl:if test="../@person-group-type='editor'">
                <xsl:value-of select="given-names"/><xsl:text> </xsl:text>
                <xsl:value-of select="surname"/>
                <xsl:if test="suffix">
                    <xsl:text> </xsl:text><xsl:value-of select="suffix"/>
                </xsl:if>
                <xsl:text>, </xsl:text>
                </xsl:if>
            </xsl:for-each>
            <xsl:choose>
            <xsl:when test="not($edt = 1)"><xsl:text>Eds., </xsl:text></xsl:when>
            <xsl:otherwise><xsl:text>Ed., </xsl:text></xsl:otherwise>
           	</xsl:choose>
        </xsl:if>
        </xsl:if>
	</xsl:template>
    
    <xsl:template match="person-group" mode="apa">
		<xsl:if test="@person-group-type='author'">
        <xsl:for-each select="name">
        	<xsl:value-of select="surname"/><xsl:text>, </xsl:text>
            <xsl:value-of select="given-names"/>
            <xsl:if test="suffix">
            	<xsl:text>, </xsl:text><xsl:value-of select="suffix"/>
            </xsl:if>
            <xsl:choose>
                <xsl:when test="following-sibling::name">
                    <xsl:text>, </xsl:text>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:if test="../@person-group-type='inventor'">
                        <xsl:text>, inventors;</xsl:text>
                    </xsl:if>
                    <xsl:text> </xsl:text>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:for-each>
        
        <xsl:if test="../year and not(../collab)">
        	<xsl:text>(</xsl:text><xsl:value-of select="../year"/><xsl:text>). </xsl:text>
        </xsl:if>
        </xsl:if>
        <xsl:if test="not(preceding-sibling::person-group/@person-group-type='author')">
            <xsl:if test="@person-group-type='editor'">
            	<xsl:for-each select="name">
                <xsl:value-of select="surname"/><xsl:text>, </xsl:text>
                <xsl:value-of select="given-names"/>
                <xsl:if test="suffix">
                    <xsl:text>, </xsl:text><xsl:value-of select="suffix"/>
                </xsl:if>
                <xsl:choose>
                    <xsl:when test="following-sibling::name">
                        <xsl:text>, </xsl:text>
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:if test="../@person-group-type='inventor'">
                            <xsl:text>, inventors;</xsl:text>
                        </xsl:if>
                        <xsl:text> </xsl:text>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:for-each>
            
            <xsl:if test="../year and not(../collab)">
                <xsl:text>(</xsl:text><xsl:value-of select="../year"/><xsl:text>). </xsl:text>
            </xsl:if>
            </xsl:if>
        </xsl:if>
	</xsl:template>
    
    <xsl:template match="person-group" mode="harvard">
    	<xsl:variable name="nv" select="count(name)"/>
		<xsl:if test="@person-group-type='author'">
        <xsl:for-each select="name">
        	<xsl:value-of select="surname"/><xsl:text>, </xsl:text>
            <xsl:value-of select="translate(given-names,'.','')"/>
            <xsl:if test="suffix">
            	<xsl:text>, </xsl:text><xsl:value-of select="suffix"/>
            </xsl:if>
            <xsl:choose>
                <xsl:when test="following-sibling::name">
                	<xsl:choose>
                    	<xsl:when test="position() = ($nv - 1)">
                        	<xsl:text> &amp; </xsl:text>
                        </xsl:when>
                        <xsl:otherwise>
                        	<xsl:text>, </xsl:text>
                        </xsl:otherwise>
                    </xsl:choose>
                    
                </xsl:when>
                <xsl:otherwise>
                    <xsl:if test="../@person-group-type='inventor'">
                        <xsl:text>, inventors;</xsl:text>
                    </xsl:if>
                    <xsl:text> </xsl:text>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:for-each>
        
        <xsl:if test="../year and not(../collab)">
        	<xsl:text>(</xsl:text><xsl:value-of select="../year"/><xsl:text>) </xsl:text>
        </xsl:if>
        </xsl:if>
        <xsl:if test="not(preceding-sibling::person-group/@person-group-type='author')">
            <xsl:if test="@person-group-type='editor'">
            	<xsl:for-each select="name">
                <xsl:value-of select="surname"/><xsl:text>, </xsl:text>
                <xsl:value-of select="translate(given-names,'.','')"/>
                <xsl:if test="suffix">
                    <xsl:text>, </xsl:text><xsl:value-of select="suffix"/>
                </xsl:if>
                <xsl:choose>
                    <xsl:when test="following-sibling::name">
                        <xsl:text>, </xsl:text>
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:if test="../@person-group-type='inventor'">
                            <xsl:text>, inventors;</xsl:text>
                        </xsl:if>
                        <xsl:text> </xsl:text>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:for-each>
            
            <xsl:if test="../year and not(../collab)">
                <xsl:text>(</xsl:text><xsl:value-of select="../year"/><xsl:text>). </xsl:text>
            </xsl:if>
            </xsl:if>
        </xsl:if>
	</xsl:template>
    
    <xsl:template match="person-group" mode="vancouver">
        <xsl:variable name="nv" select="count(name)"/>
        <xsl:variable name="nvr">
        	<xsl:choose>
                <xsl:when test="$nv &gt; 6">
                    <xsl:text>3</xsl:text>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:value-of select="$nv"/>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:variable>
        <xsl:if test="@person-group-type='author'">
            <xsl:for-each select="name">
                <xsl:if test="position() &lt;= $nvr">
                    <xsl:value-of select="surname"/><xsl:text> </xsl:text>
                    <xsl:value-of select="translate(given-names,'.','')"/>
                    <xsl:if test="suffix">
                        <xsl:text> </xsl:text><xsl:value-of select="suffix"/>
                        <!--<xsl:if test="not(position() = $nv)">
                        	<xsl:text>.</xsl:text>
                        </xsl:if>-->
                    </xsl:if>
                    <xsl:choose>
                        <xsl:when test="following-sibling::name">
                            <xsl:text>, </xsl:text>
                        </xsl:when>
                        <xsl:when test="following-sibling::etal">
                            <xsl:text>, </xsl:text><em><xsl:text>et al. </xsl:text></em>
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:if test="../@person-group-type='inventor'">
                                <xsl:text>, inventors;</xsl:text>
                            </xsl:if>
                            <xsl:text>. </xsl:text>
                        </xsl:otherwise>
                    </xsl:choose>
                </xsl:if>
            </xsl:for-each>
            <xsl:if test="count(name) &gt; 6 ">
                <em><xsl:text>et al. </xsl:text></em>
            </xsl:if>
        </xsl:if>
        <xsl:if test="not(preceding-sibling::person-group/@person-group-type='author')">
            <xsl:if test="@person-group-type='editor'">
            <xsl:for-each select="name">
                <xsl:if test="position() &lt;= $nvr">
                    <xsl:value-of select="surname"/><xsl:text> </xsl:text>
                    <xsl:value-of select="translate(given-names,'.','')"/>
                    <xsl:if test="suffix">
                        <xsl:text> </xsl:text><xsl:value-of select="suffix"/>
                        <!--<xsl:if test="not(position() = $nv)">
                        	<xsl:text>.</xsl:text>
                        </xsl:if>-->
                    </xsl:if>
                    <xsl:choose>
                        <xsl:when test="following-sibling::name">
                            <xsl:text>, </xsl:text>
                        </xsl:when>
                        
                    </xsl:choose>
                </xsl:if>
            </xsl:for-each>
            <xsl:choose>
            <xsl:when test="count(name) &gt; 6 ">
                <xsl:text>Eds.,</xsl:text><em><xsl:text> et al. </xsl:text></em>
            </xsl:when>
            <xsl:when test="count(name) = 1">
                <xsl:text>, Ed. </xsl:text>
            </xsl:when>
            <xsl:otherwise>
            	<xsl:text>, Eds. </xsl:text>
            </xsl:otherwise>
            </xsl:choose>
            </xsl:if>
        </xsl:if>
	</xsl:template>
    
	
    <xsl:template match="collab" mode="acs">
		<xsl:apply-templates/>
		<xsl:if test="@collab-type">
			<xsl:text>, </xsl:text>
			<xsl:value-of select="@collab-type"/>
		</xsl:if>

		<xsl:choose>
			<xsl:when test="following-sibling::collab">
				<xsl:text>; </xsl:text>
			</xsl:when>

			<xsl:otherwise>
				<xsl:text>. </xsl:text>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
    
	<xsl:template match="collab" mode="ieee">
		<xsl:apply-templates/>
		<xsl:if test="@collab-type">
			<xsl:text>, </xsl:text>
			<xsl:value-of select="@collab-type"/>
		</xsl:if>

		<xsl:choose>
			<xsl:when test="following-sibling::collab">
				<xsl:text>; </xsl:text>
			</xsl:when>

			<xsl:otherwise>
				<xsl:text>, </xsl:text>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
    
    <xsl:template match="collab" mode="apa">
		<xsl:apply-templates/>
		<xsl:if test="@collab-type">
			<xsl:text>, </xsl:text>
			<xsl:value-of select="@collab-type"/>
		</xsl:if>

		<xsl:choose>
			<xsl:when test="following-sibling::collab">
				<xsl:text>; </xsl:text>
			</xsl:when>

			<xsl:otherwise>
				<xsl:text>. </xsl:text>
			</xsl:otherwise>
		</xsl:choose>
        <xsl:if test="../year">
            <xsl:text>(</xsl:text><xsl:value-of select="../year"/><xsl:text>). </xsl:text>
        </xsl:if>
	</xsl:template>
    
    <xsl:template match="collab" mode="harvard">
		<xsl:apply-templates/>
		<xsl:if test="@collab-type">
			<xsl:text>, </xsl:text>
			<xsl:value-of select="@collab-type"/>
		</xsl:if>

		<xsl:choose>
			<xsl:when test="following-sibling::collab">
				<xsl:text>; </xsl:text>
			</xsl:when>

			<xsl:otherwise>
				<xsl:text>. </xsl:text>
			</xsl:otherwise>
		</xsl:choose>
        <xsl:if test="../year">
            <xsl:text>(</xsl:text><xsl:value-of select="../year"/><xsl:text>). </xsl:text>
        </xsl:if>
	</xsl:template>

	<xsl:template match="collab" mode="none">
		<xsl:apply-templates/>
		<xsl:if test="@collab-type">
			<xsl:text>, </xsl:text>
			<xsl:value-of select="@collab-type"/>
		</xsl:if>

		<xsl:choose>
			<xsl:when test="following-sibling::collab">
				<xsl:text>; </xsl:text>
			</xsl:when>

			<xsl:otherwise>
				<xsl:text>. </xsl:text>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
    
    <xsl:template match="collab" mode="vancouver">
		<xsl:apply-templates/>
		<xsl:if test="@collab-type">
			<xsl:text>, </xsl:text>
			<xsl:value-of select="@collab-type"/>
		</xsl:if>

		<xsl:choose>
			<xsl:when test="following-sibling::collab">
				<xsl:text>; </xsl:text>
			</xsl:when>

			<xsl:otherwise>
				<xsl:text>. </xsl:text>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	
    
    <xsl:template match="source" mode="acs">
    	<xsl:variable name="edt"><xsl:value-of select="count(../person-group[@person-group-type='editor']/name)"/></xsl:variable>
		<xsl:if test="../article-title and (../@citation-type='book' or ../@citation-type='confpaper')">
        	<xsl:text>In: </xsl:text>
        </xsl:if>
        <xsl:if test="count(../person-group[@person-group-type='author'])=0">
            
            <xsl:for-each select="../person-group">
                <xsl:if test="@person-group-type='editor'">
                    <xsl:for-each select="name">
                        <xsl:value-of select="surname"/><xsl:text>, </xsl:text>
                        <xsl:value-of select="given-names"/>
                        <xsl:if test="suffix">
                            <xsl:text>, </xsl:text><xsl:value-of select="suffix"/>
                        </xsl:if>
                        <xsl:choose>
                            <xsl:when test="following-sibling::name">
                                <xsl:text>; </xsl:text>
                            </xsl:when>
                            <xsl:otherwise>
                                <xsl:choose>
                                    <xsl:when test="not($edt = 1)"><xsl:text>, Eds.; </xsl:text></xsl:when>
                                    <xsl:otherwise><xsl:text>, Ed.; </xsl:text></xsl:otherwise>
                                </xsl:choose>
                            </xsl:otherwise>
                        </xsl:choose>
                    </xsl:for-each>
                </xsl:if>
            </xsl:for-each>
            </xsl:if>
        
        <xsl:choose>
            <xsl:when test="../@citation-type='thesis'">
                <xsl:choose>
                    <xsl:when test="substring(.,string-length(.),1)='.' and ../@citation-type='book'">
                        <xsl:value-of select="substring(.,1,string-length(.)-1)"/>
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:apply-templates/>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:when>
            <xsl:when test="../@citation-type='confpaper'">
                <xsl:choose>
                    <xsl:when test="substring(.,string-length(.),1)='.' and ../@citation-type='book'">
                        <xsl:value-of select="substring(.,1,string-length(.)-1)"/>
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:apply-templates/>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:when>
            <xsl:otherwise>
                <em>
                    <xsl:choose>
                        <xsl:when test="substring(.,string-length(.),1)='.' and ../@citation-type='book'">
                            <xsl:value-of select="substring(.,1,string-length(.)-1)"/>
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:apply-templates/>
                        </xsl:otherwise>
                    </xsl:choose>
                </em>
            </xsl:otherwise>
        </xsl:choose>
        <xsl:choose>
        <xsl:when test="../@citation-type='book' or ../@citation-type='confpaper'">
            <xsl:if test="../edition">
            	<em><xsl:text>, </xsl:text></em>
            	<xsl:apply-templates select="../edition" mode="acs-explicit"/>
            </xsl:if>
            <xsl:text>; </xsl:text>
            
            <xsl:if test="count(../person-group[@person-group-type='author'])=1">
            
            <xsl:for-each select="../person-group">
                <xsl:if test="@person-group-type='editor'">
                    <xsl:for-each select="name">
                        <xsl:value-of select="surname"/><xsl:text>, </xsl:text>
                        <xsl:value-of select="given-names"/>
                        <xsl:if test="suffix">
                            <xsl:text>, </xsl:text><xsl:value-of select="suffix"/>
                        </xsl:if>
                        <xsl:choose>
                            <xsl:when test="following-sibling::name">
                                <xsl:text>; </xsl:text>
                            </xsl:when>
                            <xsl:otherwise>
                                <xsl:choose>
                                    <xsl:when test="not($edt = 1)"><xsl:text>, Eds.; </xsl:text></xsl:when>
                                    <xsl:otherwise><xsl:text>, Ed.; </xsl:text></xsl:otherwise>
                                </xsl:choose>
                            </xsl:otherwise>
                        </xsl:choose>
                    </xsl:for-each>
                </xsl:if>
            </xsl:for-each>
            </xsl:if>
        </xsl:when>
        <xsl:when test="../@citation-type='patent'">
        	<xsl:text> </xsl:text>
        </xsl:when>
        <xsl:otherwise>
            <i><xsl:text>, </xsl:text></i>
        </xsl:otherwise>
        </xsl:choose>
		<xsl:if test="not(../@citation-type='book')">
		<xsl:choose>
			<xsl:when test="../access-date">
				<xsl:if test="../edition">
					<xsl:text> (</xsl:text>
					<xsl:apply-templates select="../edition" mode="acs"/>
					<xsl:text>)</xsl:text><xsl:text>, </xsl:text>
				</xsl:if>
				
			</xsl:when>

			<xsl:when test="../volume | ../fpage">
				<xsl:if test="../edition">
					<xsl:text> (</xsl:text>
					<xsl:apply-templates select="../edition" mode="acs"/>
					<xsl:text>)</xsl:text>
				</xsl:if>
				<xsl:text> </xsl:text>
			</xsl:when>

			<xsl:otherwise>
				<xsl:if test="../edition">
					<xsl:text> (</xsl:text>
					<xsl:apply-templates select="../edition" mode="acs"/>
					<xsl:text>)</xsl:text>
                    <xsl:text>, </xsl:text>
				</xsl:if>
				
			</xsl:otherwise>
		</xsl:choose>
        </xsl:if>
	</xsl:template>
    
    
    <xsl:template match="source" mode="ieee">
        <xsl:choose>
            <xsl:when test="not(../@citation-type='thesis') and not(../@citation-type='patent')">
                <em>
                    <xsl:apply-templates/>
                </em>
            </xsl:when>
            <xsl:otherwise>
                <xsl:apply-templates/>
            </xsl:otherwise>
        </xsl:choose>
        <xsl:if test="../volume or ../issue or ../fpage or ../lpage or ../year">
            <xsl:choose>
                <xsl:when test="(../volume or ../edition) and ../@citation-type='book'">
                    <em><xsl:text>, </xsl:text></em>
                </xsl:when>
                <xsl:when test="../@citation-type='book'">
                    <em><xsl:text>, </xsl:text></em>
                </xsl:when>
                <xsl:otherwise>
                    <em><xsl:text>, </xsl:text></em>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:if>
        <xsl:if test="../volume">
        	<xsl:apply-templates select="../volume" mode="ieee-explicit"/>
        </xsl:if>
        <xsl:if test="../edition">
        	<xsl:apply-templates select="../edition" mode="ieee-explicit"/>
        </xsl:if>
        <xsl:if test="../publisher-name and not(../@citation-type='confproc')">
        	<xsl:apply-templates select="../publisher-name" mode="ieee-explicit"/>
        </xsl:if>
        <xsl:if test="../publisher-name and ../publisher-loc and not(../@citation-type='confproc')">
        	<xsl:choose>
                <xsl:when test="../@citation-type='thesis'">
                	<xsl:text>, </xsl:text>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:text>: </xsl:text>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:if>
        <xsl:if test="../publisher-loc and not(../@citation-type='confproc')">
        	<xsl:apply-templates select="../publisher-loc" mode="ieee-explicit"/>
        </xsl:if>
        <xsl:if test="../publisher-name or ../publisher-loc and not(../@citation-type='confproc')">
        	<xsl:text>, </xsl:text>
        </xsl:if>
        <xsl:if test="../year and ../@citation-type='book'">
        	<xsl:apply-templates select="../year" mode="ieee-explicit"/>
            <xsl:if test="../fpage">
                <xsl:text>, </xsl:text>
            </xsl:if>
        </xsl:if>
        <xsl:if test="../year and ../@citation-type='web'">
        	<xsl:apply-templates select="../year" mode="ieee-explicit"/>
        </xsl:if>
        <xsl:if test="../year and ../@citation-type='confproc'">
        	<xsl:apply-templates select="../year" mode="ieee-explicit"/>
        </xsl:if>
        <xsl:if test="../issue">
        	<xsl:apply-templates select="../issue" mode="ieee-explicit"/>
        </xsl:if>
        <xsl:if test="../supplement">
        	<xsl:apply-templates select="../supplement" mode="ieee-explicit"/>
        </xsl:if>
        <xsl:if test="../fpage">
        	<xsl:apply-templates select="../fpage" mode="ieee-explicit"/>
        </xsl:if>
        <xsl:if test="../lpage">
        	<xsl:apply-templates select="../lpage" mode="ieee-explicit"/>
        </xsl:if>
        <xsl:if test="../fpage and ../@citation-type='journal'">
        	<xsl:text>, </xsl:text>
        </xsl:if>
        <xsl:if test="../year and (../@citation-type='journal' or ../@citation-type='thesis' or ../@citation-type='patent')">
        	<xsl:apply-templates select="../year" mode="ieee-explicit"/>
        </xsl:if>
        <xsl:choose>
            <xsl:when test="../@citation-type='confproc'">
                <xsl:text> </xsl:text>
            </xsl:when>
            <xsl:otherwise>
                <xsl:text>.</xsl:text>
            </xsl:otherwise>
        </xsl:choose>
	</xsl:template>
    
    <xsl:template match="source" mode="apa">
		<i>
<!--		<xsl:choose>
        <xsl:when test="substring(.,string-length(.),1)='.'">
            <xsl:value-of select="substring(.,1,string-length(.)-1)"/>
        </xsl:when>
        <xsl:otherwise>-->
        	<xsl:apply-templates/>
<!--        </xsl:otherwise>
        </xsl:choose>
-->		<xsl:choose>
        <xsl:when test="(../access-date or ../volume or ../issue or ../fpage) and not(../@citation-type='book')">
        <xsl:text>, </xsl:text>
        </xsl:when>
        <xsl:when test="(../publisher-loc or ../publisher-name) and not(../edition or ../volume or ../issue or ../fpage) and ../@citation-type='book'">
        <xsl:text>. </xsl:text>
        </xsl:when>
        <xsl:when test="(../publisher-loc or ../publisher-name) and (../edition or ../volume or ../issue or ../fpage) and ../@citation-type='book'">
        <xsl:text> </xsl:text>
        </xsl:when>
        <xsl:when test="not(../access-date) and not(../volume) and not(../issue) and not(../fpage) and not(../publisher-loc) and not(../publisher-name)">
        	<xsl:if test="not(substring(.,string-length(.),1)='.')">
                <xsl:text>.</xsl:text>
            </xsl:if>
        </xsl:when>
        </xsl:choose>
		</i>
		<xsl:choose>
			<xsl:when test="../access-date">
				<xsl:if test="../edition and not(../@citation-type='book')">
					<xsl:text> (</xsl:text>
					<xsl:apply-templates select="../edition" mode="apa"/>
					<xsl:text>)</xsl:text>
				</xsl:if>
				<xsl:if test="not(../@citation-type='web')">
                	<xsl:text>, </xsl:text>
                </xsl:if>
			</xsl:when>

			<xsl:when test="../volume | ../fpage">
				<xsl:if test="../edition and not(../@citation-type='book')">
					<xsl:text> (</xsl:text>
					<xsl:apply-templates select="../edition" mode="apa"/>
					<xsl:text>)</xsl:text>
				</xsl:if>
				<xsl:text> </xsl:text>
			</xsl:when>

			<xsl:otherwise>
				<xsl:if test="../edition and not(../@citation-type='book')">
					<xsl:text> (</xsl:text>
					<xsl:apply-templates select="../edition" mode="apa"/>
					<xsl:text>)</xsl:text>
                    <xsl:text>, </xsl:text>
				</xsl:if>
				
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
    
    <xsl:template match="source" mode="harvard">
		<i>
        	<xsl:choose>
                <xsl:when test="not(uri) and not(sub) and not(sup)">
                    <xsl:value-of select="translate(.,'.','')" disable-output-escaping="yes"/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:apply-templates mode="harvard"/>
                </xsl:otherwise>
            </xsl:choose>
		<xsl:choose>
        <xsl:when test="(../access-date or ../volume or ../issue or ../fpage) and not(../@citation-type='book')">
            <xsl:text>, </xsl:text>
        </xsl:when>
        <xsl:when test="(../publisher-loc or ../publisher-name) and not(../edition or ../volume or ../issue or ../fpage) and ../@citation-type='book'">
            <xsl:text>. </xsl:text>
        </xsl:when>
        <xsl:when test="(../publisher-loc or ../publisher-name) and (../volume or ../issue or ../fpage) and ../@citation-type='book'">
            <xsl:text>, </xsl:text>
        </xsl:when>
        <xsl:when test="(../publisher-loc or ../publisher-name) and (../edition) and ../@citation-type='book'">
            <xsl:text> </xsl:text>
        </xsl:when>
        <xsl:when test="not(../access-date) and not(../volume) and not(../issue) and not(../fpage) and not(../publisher-loc) and not(../publisher-name)">
        	<xsl:if test="not(substring(.,string-length(.),1)='.')">
                <xsl:text>.</xsl:text>
            </xsl:if>
        </xsl:when>
        </xsl:choose>
		</i>
		<xsl:choose>
			<xsl:when test="../access-date">
				<xsl:if test="../edition and not(../@citation-type='book')">
					<xsl:text> (</xsl:text>
					<xsl:apply-templates select="../edition" mode="harvard"/>
					<xsl:text>)</xsl:text>
				</xsl:if>
				<xsl:if test="not(../@citation-type='web')">
                	<xsl:text>, </xsl:text>
                </xsl:if>
			</xsl:when>

			<xsl:when test="../volume | ../fpage">
				<xsl:if test="../edition and not(../@citation-type='book')">
					<xsl:text> (</xsl:text>
					<xsl:apply-templates select="../edition" mode="harvard"/>
					<xsl:text>)</xsl:text>
				</xsl:if>
				<xsl:text> </xsl:text>
			</xsl:when>
            <xsl:when test="../edition">
                <xsl:text>, </xsl:text>
                <xsl:apply-templates select="../edition" mode="harvard"/>
                <xsl:text>, </xsl:text>
            </xsl:when>
			<xsl:otherwise>
				<xsl:if test="../edition and not(../@citation-type='book')">
					<xsl:text> (</xsl:text>
					<xsl:apply-templates select="../edition" mode="harvard"/>
					<xsl:text>)</xsl:text>
                    <xsl:text>, </xsl:text>
				</xsl:if>
				
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
    
    <xsl:template match="access-date" mode="apa">
    	<xsl:text>[</xsl:text>
        <xsl:apply-templates />
        <xsl:text>]</xsl:text>
        <xsl:if test="not(../fpage)">
        	<xsl:text>.</xsl:text>
        </xsl:if>
    </xsl:template>
    
    <xsl:template match="access-date" mode="harvard">
    	<xsl:text>[</xsl:text>
        <xsl:apply-templates />
        <xsl:text>]</xsl:text>
        <xsl:if test="not(../fpage)">
        	<xsl:text>.</xsl:text>
        </xsl:if>
    </xsl:template>
    
    <xsl:template match="source" mode="vancouver">
        <xsl:choose>
            <xsl:when test="not(uri)">
                <xsl:value-of select="translate(.,'.','')" disable-output-escaping="yes"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:apply-templates mode="vancouver"/>
            </xsl:otherwise>
        </xsl:choose>
        <xsl:choose>
            <xsl:when test="../@citation-type='book'">
                <xsl:text>. </xsl:text>
            </xsl:when>
            <xsl:when test="../@citation-type='confproc'">
                <xsl:text>. </xsl:text>
            </xsl:when>
			<xsl:when test="../@citation-type='thesis'">
				<xsl:text>. </xsl:text>
				<xsl:if test="../publisher-loc">
					<xsl:apply-templates select="../publisher-loc" mode="vancouver-explicit"/>
				</xsl:if>
				<xsl:if test="../publisher-name">
					<xsl:text>: </xsl:text>
					<xsl:apply-templates select="../publisher-name" mode="vancouver-explicit"/>
				</xsl:if>
				<xsl:if test="../publisher-loc or ./publisher-name">
					<xsl:text> </xsl:text>
				</xsl:if>
			</xsl:when>
            <xsl:otherwise>
                <xsl:text> </xsl:text>
            </xsl:otherwise>
		</xsl:choose>
		<xsl:choose>
			<xsl:when test="../access-date">
				<xsl:if test="../edition">
					<xsl:text> </xsl:text>
					<xsl:apply-templates select="../edition" mode="vancouver"/>
					<xsl:text></xsl:text>
				</xsl:if>
				<xsl:text> </xsl:text>
			</xsl:when>

			<xsl:when test="../volume | ../fpage">
				<xsl:if test="../edition">
					<xsl:text> </xsl:text>
					<xsl:apply-templates select="../edition" mode="vancouver"/>
					<xsl:text></xsl:text>
				</xsl:if>
				<xsl:text> </xsl:text>
			</xsl:when>

			<xsl:otherwise>
				<xsl:if test="../edition">
					<xsl:text> </xsl:text>
					<xsl:apply-templates select="../edition" mode="vancouver"/>
					<xsl:text></xsl:text>
                    <xsl:text> </xsl:text>
				</xsl:if>
				
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
    
    
	<xsl:template match="source" mode="none">
		<i>
		<xsl:apply-templates/>
		<xsl:text>.</xsl:text>
		</i>
		<xsl:choose>
			<xsl:when test="../access-date">
				<xsl:if test="../edition">
					<xsl:text> (</xsl:text>
					<xsl:apply-templates select="../edition" mode="plain"/>
					<xsl:text>)</xsl:text>
				</xsl:if>
				<xsl:text>. </xsl:text>
			</xsl:when>

			<xsl:when test="../volume | ../fpage">
				<xsl:if test="../edition">
					<xsl:text> (</xsl:text>
					<xsl:apply-templates select="../edition" mode="plain"/>
					<xsl:text>)</xsl:text>
				</xsl:if>
				<xsl:text> </xsl:text>
			</xsl:when>

			<xsl:otherwise>
				<xsl:if test="../edition">
					<xsl:text> (</xsl:text>
					<xsl:apply-templates select="../edition" mode="plain"/>
					<xsl:text>)</xsl:text>
				</xsl:if>
				<xsl:text>. </xsl:text>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<xsl:template match="trans-title" mode="none">
		<xsl:text> [</xsl:text>
		<xsl:apply-templates/>
		<xsl:text>]. </xsl:text>
	</xsl:template>
    
    <xsl:template match="trans-title" mode="acs">
		<xsl:text> [</xsl:text>
		<xsl:apply-templates/>
		<xsl:text>]. </xsl:text>
	</xsl:template>
    
    <xsl:template match="trans-title" mode="apa">
		<xsl:text> [</xsl:text>
		<xsl:apply-templates/>
		<xsl:text>]. </xsl:text>
	</xsl:template>

	<xsl:template match="trans-title" mode="harvard">
		<xsl:text> [</xsl:text>
		<xsl:apply-templates/>
		<xsl:text>]. </xsl:text>
	</xsl:template>

	<xsl:template match="trans-title" mode="vancouver">
		<xsl:text> [</xsl:text>
		<xsl:apply-templates/>
		<xsl:text>]. </xsl:text>
	</xsl:template>

	<xsl:template match="month" mode="none">
		<xsl:variable name="month" select="."/>
		<xsl:choose>
			<xsl:when test="$month='01' or $month='1' ">Jan</xsl:when>
			<xsl:when test="$month='02' or $month='2' ">Feb</xsl:when>
			<xsl:when test="$month='03' or $month='3' ">Mar</xsl:when>
			<xsl:when test="$month='04' or $month='4' ">Apr</xsl:when>
			<xsl:when test="$month='05' or $month='5' ">May</xsl:when>
			<xsl:when test="$month='06' or $month='6'">Jun</xsl:when>
			<xsl:when test="$month='07' or $month='7'">Jul</xsl:when>
			<xsl:when test="$month='08' or $month='8' ">Aug</xsl:when>
			<xsl:when test="$month='09' or $month='9' ">Sep</xsl:when>
			<xsl:when test="$month='10' ">Oct</xsl:when>
			<xsl:when test="$month='11' ">Nov</xsl:when>
			<xsl:when test="$month='12' ">Dec</xsl:when>

			<xsl:otherwise>
				<xsl:value-of select="$month"/>
			</xsl:otherwise>
		</xsl:choose>

		<xsl:if test="../day">
			<xsl:text> </xsl:text>
			<xsl:value-of select="../day"/>
		</xsl:if>

		<xsl:text>;</xsl:text>

	</xsl:template>
	
    <xsl:template match="month" mode="ieee"/>
    
    <xsl:template match="month" mode="ieee-explicit">
		<xsl:variable name="month" select="."/>
		<xsl:choose>
			<xsl:when test="$month='01' or $month='1' ">Jan</xsl:when>
			<xsl:when test="$month='02' or $month='2' ">Feb</xsl:when>
			<xsl:when test="$month='03' or $month='3' ">Mar</xsl:when>
			<xsl:when test="$month='04' or $month='4' ">Apr</xsl:when>
			<xsl:when test="$month='05' or $month='5' ">May</xsl:when>
			<xsl:when test="$month='06' or $month='6'">Jun</xsl:when>
			<xsl:when test="$month='07' or $month='7'">Jul</xsl:when>
			<xsl:when test="$month='08' or $month='8' ">Aug</xsl:when>
			<xsl:when test="$month='09' or $month='9' ">Sep</xsl:when>
			<xsl:when test="$month='10' ">Oct</xsl:when>
			<xsl:when test="$month='11' ">Nov</xsl:when>
			<xsl:when test="$month='12' ">Dec</xsl:when>

			<xsl:otherwise>
				<xsl:value-of select="$month"/>
			</xsl:otherwise>
		</xsl:choose>

		<xsl:if test="../day">
			<xsl:text> </xsl:text>
			<xsl:value-of select="../day"/>
            <xsl:text>,</xsl:text>
		</xsl:if>

		<xsl:text> </xsl:text>

	</xsl:template>
    
    <xsl:template match="month" mode="acs">
		<xsl:variable name="month" select="."/>
		<xsl:choose>
			<xsl:when test="$month='01' or $month='1' ">Jan</xsl:when>
			<xsl:when test="$month='02' or $month='2' ">Feb</xsl:when>
			<xsl:when test="$month='03' or $month='3' ">Mar</xsl:when>
			<xsl:when test="$month='04' or $month='4' ">Apr</xsl:when>
			<xsl:when test="$month='05' or $month='5' ">May</xsl:when>
			<xsl:when test="$month='06' or $month='6'">Jun</xsl:when>
			<xsl:when test="$month='07' or $month='7'">Jul</xsl:when>
			<xsl:when test="$month='08' or $month='8' ">Aug</xsl:when>
			<xsl:when test="$month='09' or $month='9' ">Sep</xsl:when>
			<xsl:when test="$month='10' ">Oct</xsl:when>
			<xsl:when test="$month='11' ">Nov</xsl:when>
			<xsl:when test="$month='12' ">Dec</xsl:when>

			<xsl:otherwise>
				<xsl:value-of select="$month"/>
			</xsl:otherwise>
		</xsl:choose>

		<xsl:if test="../day">
			<xsl:text> </xsl:text>
			<xsl:value-of select="../day"/>
		</xsl:if>

		<xsl:text>;</xsl:text>

	</xsl:template>
    
    <xsl:template match="month" mode="apa">
		<xsl:variable name="month" select="."/>
		<xsl:choose>
			<xsl:when test="$month='01' or $month='1' ">Jan</xsl:when>
			<xsl:when test="$month='02' or $month='2' ">Feb</xsl:when>
			<xsl:when test="$month='03' or $month='3' ">Mar</xsl:when>
			<xsl:when test="$month='04' or $month='4' ">Apr</xsl:when>
			<xsl:when test="$month='05' or $month='5' ">May</xsl:when>
			<xsl:when test="$month='06' or $month='6'">Jun</xsl:when>
			<xsl:when test="$month='07' or $month='7'">Jul</xsl:when>
			<xsl:when test="$month='08' or $month='8' ">Aug</xsl:when>
			<xsl:when test="$month='09' or $month='9' ">Sep</xsl:when>
			<xsl:when test="$month='10' ">Oct</xsl:when>
			<xsl:when test="$month='11' ">Nov</xsl:when>
			<xsl:when test="$month='12' ">Dec</xsl:when>

			<xsl:otherwise>
				<xsl:value-of select="$month"/>
			</xsl:otherwise>
		</xsl:choose>

		<xsl:if test="../day">
			<xsl:text> </xsl:text>
			<xsl:value-of select="../day"/>
		</xsl:if>

		<xsl:text>;</xsl:text>

	</xsl:template>
    
    <xsl:template match="month" mode="harvard">
		<xsl:variable name="month" select="."/>
		<xsl:choose>
			<xsl:when test="$month='01' or $month='1' ">Jan</xsl:when>
			<xsl:when test="$month='02' or $month='2' ">Feb</xsl:when>
			<xsl:when test="$month='03' or $month='3' ">Mar</xsl:when>
			<xsl:when test="$month='04' or $month='4' ">Apr</xsl:when>
			<xsl:when test="$month='05' or $month='5' ">May</xsl:when>
			<xsl:when test="$month='06' or $month='6'">Jun</xsl:when>
			<xsl:when test="$month='07' or $month='7'">Jul</xsl:when>
			<xsl:when test="$month='08' or $month='8' ">Aug</xsl:when>
			<xsl:when test="$month='09' or $month='9' ">Sep</xsl:when>
			<xsl:when test="$month='10' ">Oct</xsl:when>
			<xsl:when test="$month='11' ">Nov</xsl:when>
			<xsl:when test="$month='12' ">Dec</xsl:when>

			<xsl:otherwise>
				<xsl:value-of select="$month"/>
			</xsl:otherwise>
		</xsl:choose>

		<xsl:if test="../day">
			<xsl:text> </xsl:text>
			<xsl:value-of select="../day"/>
		</xsl:if>

		<xsl:text>;</xsl:text>

	</xsl:template>
    
    <xsl:template match="month" mode="vancouver"/>
    
    <xsl:template match="month" mode="vancouver-explicit">
    	
		<xsl:variable name="month" select="."/>
		<xsl:choose>
			<xsl:when test="$month='01' or $month='1' ">Jan</xsl:when>
			<xsl:when test="$month='02' or $month='2' ">Feb</xsl:when>
			<xsl:when test="$month='03' or $month='3' ">Mar</xsl:when>
			<xsl:when test="$month='04' or $month='4' ">Apr</xsl:when>
			<xsl:when test="$month='05' or $month='5' ">May</xsl:when>
			<xsl:when test="$month='06' or $month='6'">Jun</xsl:when>
			<xsl:when test="$month='07' or $month='7'">Jul</xsl:when>
			<xsl:when test="$month='08' or $month='8' ">Aug</xsl:when>
			<xsl:when test="$month='09' or $month='9' ">Sep</xsl:when>
			<xsl:when test="$month='10' ">Oct</xsl:when>
			<xsl:when test="$month='11' ">Nov</xsl:when>
			<xsl:when test="$month='12' ">Dec</xsl:when>

			<xsl:otherwise>
				<xsl:value-of select="$month"/>
			</xsl:otherwise>
		</xsl:choose>

		<xsl:if test="../day">
			<xsl:text> </xsl:text>
			<xsl:value-of select="../day"/>
		</xsl:if>

		<xsl:text>;</xsl:text>

	</xsl:template>
    
	<xsl:template match="day" mode="none"/>
    
    <xsl:template match="day" mode="acs"/>
    
    <xsl:template match="day" mode="ieee"/>
    
    <xsl:template match="day" mode="apa"/>
    
    <xsl:template match="day" mode="harvard"/>
    
    <xsl:template match="day" mode="vancouver"/>

	<xsl:template match="year" mode="none">
		<xsl:choose>
			<xsl:when test="../month or ../season or ../access-date">
				<xsl:apply-templates mode="none"/>
				<xsl:text> </xsl:text>
			</xsl:when>

			<xsl:otherwise>
				<b><xsl:apply-templates mode="none"/>
				<xsl:if test="../volume or ../issue">
					<xsl:text>; </xsl:text>
				</xsl:if></b>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
    
    <xsl:template match="year" mode="acs">
		<xsl:choose>
        <xsl:when test="../@citation-type='book' or ../@citation-type='confpaper'">
        	<xsl:value-of select="../publisher-name"/>
        	<xsl:if test="../publisher-loc and ../publisher-name"><xsl:text>: </xsl:text></xsl:if>
        	<xsl:value-of select="../publisher-loc"/><xsl:text>, </xsl:text>
        	<strong><xsl:apply-templates/></strong>
        	<xsl:if test="../volume">
            	<xsl:choose>
                    <xsl:when test="not(../article-title)">
                        <xsl:text>, </xsl:text>
                    </xsl:when>
                    <xsl:when test="../article-title">
                        <xsl:text>; </xsl:text>
                    </xsl:when>
                </xsl:choose>
            	<xsl:value-of select="../volume"/><xsl:text>, </xsl:text>
        	</xsl:if>
            <xsl:if test="not(../volume)">
            	<xsl:choose>
                    <xsl:when test="not(../article-title) and ../fpage">
                        <xsl:text>, </xsl:text>
                    </xsl:when>
                    <xsl:when test="../article-title and ../fpage">
                        <xsl:text>; </xsl:text>
                    </xsl:when>
                </xsl:choose>
        	</xsl:if>
            <xsl:choose>
                <xsl:when test="../fpage and ../lpage">
                    <xsl:text>pp. </xsl:text>
                </xsl:when>
                <xsl:when test="../fpage and not(../lpage)">
                    <xsl:text>p. </xsl:text>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:text>. </xsl:text>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:when>
        <xsl:when test="../@citation-type='thesis'">
        	<xsl:if test="../publisher-name or ../publisher-loc">
                <xsl:apply-templates select="../publisher-name" mode="acs-explicit"/>
                <xsl:if test="../publisher-name and ../publisher-loc">
                    <xsl:text>: </xsl:text>
                </xsl:if>
                <xsl:apply-templates select="../publisher-loc" mode="acs-explicit"/>
                <xsl:text>, </xsl:text>
            </xsl:if>
        	<b><xsl:apply-templates mode="acs"/></b>
            <xsl:text>.</xsl:text>
        </xsl:when>
		<xsl:otherwise>
            <xsl:choose>
                <xsl:when test="../month or ../season or ../access-date">
                    <xsl:apply-templates mode="acs"/>
                    <xsl:text> </xsl:text>
                </xsl:when>
                <xsl:otherwise>
                    <b><xsl:apply-templates mode="acs"/></b>
                    <xsl:if test="../volume or ../issue or ../publisher-loc or ../publisher-name">
                        <xsl:text>, </xsl:text>
                    </xsl:if>
                    <xsl:if test="not(../volume or ../issue or ../fpage or ../lpage or ../publisher-loc or ../publisher-name)">
                        <xsl:text>.</xsl:text>
                    </xsl:if>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:otherwise>
        </xsl:choose>
	</xsl:template>
    
    <xsl:template match="year" mode="ieee"/>
    
    <xsl:template match="year" mode="ieee-explicit">
        <xsl:if test="../month">
            <xsl:apply-templates select="../month" mode="ieee-explicit"/>
        </xsl:if>
        <xsl:apply-templates/>
    </xsl:template>
    
    <xsl:template match="year" mode="apa"/>
    
    <xsl:template match="year" mode="harvard"/>
		
    <xsl:template match="publisher-loc" mode="acs"/>
    
	<xsl:template match="publisher-name" mode="acs"/>
    
    <xsl:template match="publisher-loc" mode="ieee"/>
    
    <xsl:template match="publisher-loc" mode="acs-explicit">
    	<xsl:apply-templates/>
    </xsl:template>
    
    <xsl:template match="publisher-name" mode="acs-explicit">
    	<xsl:apply-templates/>
    </xsl:template>
    
    <xsl:template match="publisher-loc" mode="ieee-explicit">
    	<xsl:apply-templates/>
    </xsl:template>
    
	<xsl:template match="publisher-name" mode="ieee"/>
    
    <xsl:template match="publisher-name" mode="ieee-explicit">
    	<xsl:apply-templates/>
    </xsl:template>
    
	<xsl:template match="publisher-loc" mode="vancouver"/>
    
	<xsl:template match="publisher-name" mode="vancouver"/>
    
    <xsl:template match="year" mode="vancouver">
		<xsl:choose>
        <xsl:when test="../@citation-type='book'">
        	<xsl:value-of select="../publisher-loc"/>
        	<xsl:if test="../publisher-loc and ../publisher-name"><xsl:text>: </xsl:text></xsl:if>
        	
        	<xsl:value-of select="../publisher-name"/><xsl:text> </xsl:text>
        	<xsl:apply-templates/>
            <xsl:choose>
                <xsl:when test="../volume or ../supplement or ../fpage">
                    <xsl:text>; </xsl:text>
                </xsl:when>
                <xsl:otherwise>
                	<xsl:text>.</xsl:text>
                </xsl:otherwise>
            </xsl:choose>
            <xsl:if test="../volume">
            	<xsl:value-of select="../volume"/>
            </xsl:if>
            <xsl:if test="../supplement">
            	<xsl:text>(</xsl:text>
                    <xsl:value-of select="../supplement"/>
                <xsl:text>)</xsl:text>
            </xsl:if>
            <xsl:if test="../volume or ../supplement">
            	<xsl:choose>
                    <xsl:when test="not(../fpage)">
                    	<xsl:text>.</xsl:text>
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:text>: </xsl:text>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:if>
            <xsl:choose>
                <xsl:when test="../fpage and ../lpage">
                    <xsl:text>pp. </xsl:text>
                </xsl:when>
                <xsl:when test="../fpage and not(../lpage)">
                    <xsl:text>p. </xsl:text>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:text></xsl:text>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:when>
        <xsl:otherwise>
        <xsl:choose>
			<xsl:when test="../month or ../season or ../access-date">
				<xsl:apply-templates mode="vancouver"/>
				<xsl:if test="../month"><xsl:text> </xsl:text><xsl:apply-templates select="../month" mode="vancouver-explicit"/><xsl:text> </xsl:text></xsl:if>
				
			</xsl:when>
            <xsl:when test="../@citation-type='confproc'">
            	
            </xsl:when>
			<xsl:otherwise>
				<xsl:apply-templates mode="vancouver"/>
				<xsl:if test="../volume or ../issue or ../fpage">
					<xsl:text>; </xsl:text>
				</xsl:if>
                <xsl:if test="not(../volume or ../issue or ../fpage or ../lpage)">
                	<xsl:text>.</xsl:text>
                </xsl:if>
			</xsl:otherwise>
		</xsl:choose>
        </xsl:otherwise>
        </xsl:choose>
	</xsl:template>

	<xsl:template match="conf-name" mode="vancouver">
    	
        <xsl:text> </xsl:text>
        <xsl:if test="../article-title">
        	<xsl:text>In: </xsl:text>
        </xsl:if>
        <xsl:apply-templates/>
        <xsl:text>; </xsl:text>
        <xsl:if test="not(../conf-date) and not(../conf-loc)">
        	<xsl:if test="../publisher-loc">
            <xsl:value-of select="../publisher-loc"/>
            <xsl:text>: </xsl:text>
            </xsl:if>
            <xsl:if test="../publisher-name">
            <xsl:value-of select="../publisher-name"/>
            <xsl:text> </xsl:text>
            </xsl:if>
            <xsl:if test="../year">
            <xsl:value-of select="../year"/>
                <xsl:choose>
                <xsl:when test="../fpage and ../lpage">
                    <xsl:text>; pp. </xsl:text>
                </xsl:when>
                <xsl:when test="../fpage and not(../lpage)">
                    <xsl:text>; p. </xsl:text>
                </xsl:when>
                <xsl:when test="not(../fpage) and not(../lpage)">
                    <xsl:text>.</xsl:text>
                </xsl:when>
                </xsl:choose>
            </xsl:if>
        </xsl:if>
        
    </xsl:template>
    
    <xsl:template match="conf-date" mode="vancouver">
    	<xsl:apply-templates/>
        <xsl:text>; </xsl:text>
        <xsl:if test="not(../conf-loc)">
        	<xsl:if test="../publisher-loc">
            <xsl:value-of select="../publisher-loc"/>
            <xsl:text>: </xsl:text>
            </xsl:if>
            <xsl:if test="../publisher-name">
            <xsl:value-of select="../publisher-name"/>
            <xsl:text> </xsl:text>
            </xsl:if>
            <xsl:if test="../year">
            <xsl:value-of select="../year"/>
                <xsl:choose>
                <xsl:when test="../fpage and ../lpage">
                    <xsl:text>; pp. </xsl:text>
                </xsl:when>
                <xsl:when test="../fpage and not(../lpage)">
                    <xsl:text>; p. </xsl:text>
                </xsl:when>
                <xsl:when test="not(../fpage) and not(../lpage)">
                    <xsl:text>.</xsl:text>
                </xsl:when>
                </xsl:choose>
            </xsl:if>
        </xsl:if>
        
    </xsl:template>
    
    <xsl:template match="conf-date" mode="ieee"/>
    
    <xsl:template match="conf-date" mode="ieee-explicit">
    	<em>
        <xsl:apply-templates/>
        </em>
    </xsl:template>
    
    <xsl:template match="conf-loc" mode="ieee">
        <xsl:apply-templates/>
        
        <xsl:if test="not(../source)">
            <xsl:if test="../publisher-name">
            	<xsl:text>. </xsl:text>
                <xsl:apply-templates select="../publisher-name" mode="ieee-explicit"/>
            </xsl:if>
            <xsl:if test="../publisher-name and ../publisher-loc">
            	<xsl:text>: </xsl:text>
            </xsl:if>
            <xsl:if test="../publisher-loc">
            	<xsl:if test="not(../publisher-name)">
                	<xsl:text>, </xsl:text>
                </xsl:if>
                <xsl:apply-templates select="../publisher-loc" mode="ieee-explicit"/>
            </xsl:if>
            <xsl:if test="../year">
            	<xsl:text>, </xsl:text>
            	<xsl:apply-templates select="../year" mode="ieee-explicit"/>
            </xsl:if>
            <xsl:text>.</xsl:text>
        </xsl:if>
    </xsl:template>
    
    <xsl:template match="conf-name" mode="ieee">
    	<xsl:if test="../article-title and not(../source)">
        	<xsl:text>In: </xsl:text>
        </xsl:if>
        <em><xsl:apply-templates/></em>
        <xsl:if test="../conf-date">
            	<xsl:text>, </xsl:text>
                <xsl:apply-templates select="../conf-date" mode="ieee-explicit"/>
            </xsl:if>
        <xsl:if test="../conf-loc">
        	<xsl:text>, </xsl:text>
        </xsl:if>
        <xsl:if test="not(../conf-loc)">
            
            <xsl:if test="../publisher-name">
            	<xsl:text>. </xsl:text>
                <xsl:apply-templates select="../publisher-name" mode="ieee-explicit"/>
            </xsl:if>
            <xsl:if test="../publisher-name and ../publisher-loc">
            	<xsl:text>: </xsl:text>
            </xsl:if>
            <xsl:if test="../publisher-loc">
            	<xsl:if test="not(../publisher-name)">
                	<xsl:text>, </xsl:text>
                </xsl:if>
                <xsl:apply-templates select="../publisher-loc" mode="ieee-explicit"/>
            </xsl:if>
            <xsl:if test="../year">
            	<xsl:text>, </xsl:text>
            	<xsl:apply-templates select="../year" mode="ieee-explicit"/>
            </xsl:if>
            <xsl:if test="../fpage and not(../source)">
            	<xsl:text>, </xsl:text>
            	<xsl:apply-templates select="../fpage" mode="ieee-explicit"/>
                <xsl:if test="../lpage and not(../source)">
                    <xsl:apply-templates select="../lpage" mode="ieee-explicit"/>
                </xsl:if>
            </xsl:if>
            <xsl:text>.</xsl:text>
        </xsl:if>
    </xsl:template>
    
    <xsl:template match="conf-loc" mode="vancouver">
    	<xsl:apply-templates/>
        <xsl:text>. </xsl:text>
        <xsl:if test="../publisher-loc">
        <xsl:value-of select="../publisher-loc"/>
        <xsl:text>: </xsl:text>
        </xsl:if>
        <xsl:if test="../publisher-name">
        <xsl:value-of select="../publisher-name"/>
        <xsl:text> </xsl:text>
        </xsl:if>
        <xsl:if test="../year">
        <xsl:value-of select="../year"/>
        	<xsl:choose>
            <xsl:when test="../fpage and ../lpage">
                <xsl:text>; pp. </xsl:text>
            </xsl:when>
            <xsl:when test="../fpage and not(../lpage)">
                <xsl:text>; p. </xsl:text>
            </xsl:when>
            <xsl:when test="not(../fpage) and not(../lpage)">
                <xsl:text>.</xsl:text>
            </xsl:when>
            </xsl:choose>
        </xsl:if>
    </xsl:template>

	<xsl:template match="access-date" mode="none">
		<xsl:text> [</xsl:text>
		<xsl:apply-templates/>
		<xsl:text>];</xsl:text>
	</xsl:template>
    
    <xsl:template match="access-date" mode="acs">
		<xsl:text> [</xsl:text>
		<xsl:apply-templates/>
		<xsl:text>];</xsl:text>
	</xsl:template>
    
    <xsl:template match="access-date" mode="vancouver">
		<xsl:text> [</xsl:text>
		<xsl:apply-templates/>
		<xsl:text>];</xsl:text>
	</xsl:template>

	<xsl:template match="season" mode="none">
		<xsl:apply-templates/>
		<xsl:text>;</xsl:text>
	</xsl:template>
    
    <xsl:template match="season" mode="acs">
		<xsl:apply-templates/>
		<xsl:text>;</xsl:text>
	</xsl:template>
    
    <xsl:template match="season" mode="vancouver">
		<xsl:apply-templates/>
		<xsl:text>;</xsl:text>
	</xsl:template>
	
    <xsl:template match="fpage" mode="acs">
		<xsl:variable name="fpgct" select="count(../fpage)"/>
		<xsl:variable name="lpgct" select="count(../lpage)"/>
		<xsl:variable name="hermano" select="name(following-sibling::node())"/>
		<xsl:choose>
			<xsl:when test="preceding-sibling::fpage">
				<xsl:choose>
					<xsl:when test="following-sibling::fpage">
						<xsl:text> </xsl:text>
						<xsl:apply-templates/>

						<xsl:if test="$hermano='lpage'">
							<xsl:text>-</xsl:text>
							<xsl:apply-templates select="following-sibling::lpage[1]" mode="none"/>
						</xsl:if>
						<xsl:text>,</xsl:text>
					</xsl:when>
					<xsl:otherwise>
						<xsl:text> </xsl:text>
						<xsl:apply-templates/>
						<xsl:if test="$hermano='lpage'">
							<xsl:text>-</xsl:text>
							<xsl:apply-templates select="following-sibling::lpage[1]" mode="none"/>
						</xsl:if>
						<xsl:text>.</xsl:text>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:when>
			<xsl:otherwise>
				<xsl:if test="not(../@citation-type='book' or ../@citation-type='confpaper')">
					<xsl:text>, </xsl:text>
				</xsl:if>
                <xsl:choose>
                    <xsl:when test="../lpage and ../@citation-type='confproc'">
                        <xsl:text>pp. </xsl:text>
                    </xsl:when>
                    <xsl:when test="not(../lpage) and ../@citation-type='confproc'">
                        <xsl:text>p. </xsl:text>
                    </xsl:when>
                </xsl:choose>	
				<xsl:apply-templates/>
				<xsl:choose>
					<xsl:when test="$hermano='lpage'">
						<xsl:text>-</xsl:text>
						<xsl:apply-templates select="following-sibling::lpage[1]" mode="write"/>
						<xsl:text>.</xsl:text>
					</xsl:when>
					<xsl:when test="$hermano='fpage'">
						<xsl:text>,</xsl:text>
					</xsl:when>
					<xsl:otherwise>
						<xsl:text>.</xsl:text>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:otherwise>
		</xsl:choose>

	</xsl:template>
    
    <xsl:template match="fpage" mode="ieee"/>
    
	<xsl:template match="fpage" mode="ieee-explicit">
    	<xsl:choose>
            <xsl:when test="not(../lpage)">
                <xsl:text>p. </xsl:text>
            </xsl:when>
            <xsl:otherwise>
                <xsl:text>pp. </xsl:text>
            </xsl:otherwise>
        </xsl:choose>
		<xsl:apply-templates/>
	</xsl:template>
    
    <xsl:template match="fpage" mode="apa">
		<xsl:variable name="fpgct" select="count(../fpage)"/>
		<xsl:variable name="lpgct" select="count(../lpage)"/>
		<xsl:variable name="hermano" select="name(following-sibling::node())"/>		
		<xsl:if test="not(../@citation-type='book')">
        <xsl:choose>
			<xsl:when test="preceding-sibling::fpage">
				<xsl:choose>
					<xsl:when test="following-sibling::fpage">
						<xsl:text> </xsl:text>
						<xsl:apply-templates/>

						<xsl:if test="$hermano='lpage'">
							<xsl:text>-</xsl:text>
							<xsl:apply-templates select="following-sibling::lpage[1]" mode="none"/>
						</xsl:if>
						<xsl:text>,</xsl:text>
					</xsl:when>
					<xsl:otherwise>
						<xsl:text> </xsl:text>
						<xsl:apply-templates/>
						<xsl:if test="$hermano='lpage'">
							<xsl:text>-</xsl:text>
							<xsl:apply-templates select="following-sibling::lpage[1]" mode="none"/>
						</xsl:if>
						<xsl:text>.</xsl:text>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:when>
			<xsl:otherwise>
				<xsl:if test="../volume">
                <xsl:text>, </xsl:text>
                </xsl:if>
				<xsl:apply-templates/>
				<xsl:choose>
					<xsl:when test="$hermano='lpage'">
						<xsl:text>-</xsl:text>
						<xsl:apply-templates select="following-sibling::lpage[1]" mode="write"/>
						<xsl:text>.</xsl:text>
					</xsl:when>
					<xsl:when test="$hermano='fpage'">
						<xsl:text>,</xsl:text>
					</xsl:when>
					<xsl:otherwise>
						<xsl:text>.</xsl:text>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:otherwise>
		</xsl:choose>
		</xsl:if>
	</xsl:template>
    
    <xsl:template match="fpage" mode="harvard">
    	<xsl:if test="not(../@citation-type='book')">
            <xsl:if test="../volume">
                <xsl:text>, </xsl:text>
            </xsl:if>
        </xsl:if>
		<xsl:value-of select="."/>
        <xsl:choose>
            <xsl:when test="following-sibling::lpage">
                <xsl:text>-</xsl:text>
                <xsl:choose>
                    <xsl:when test="string-length(.) = 7">
                         <xsl:choose>
                            <xsl:when test="string-length(.) &lt; string-length(../lpage)">
                                <xsl:value-of select="../lpage"/>
                            </xsl:when>
                            <xsl:when test="substring(.,1,6) = substring(../lpage,1,6)">
                            	<xsl:value-of select="substring(../lpage,7,1)"/>
                            </xsl:when>
                            <xsl:when test="substring(.,1,5) = substring(../lpage,1,5)">
                            	<xsl:value-of select="substring(../lpage,6,2)"/>
                            </xsl:when>
                            <xsl:when test="substring(.,1,4) = substring(../lpage,1,4)">
                            	<xsl:value-of select="substring(../lpage,5,3)"/>
                            </xsl:when>
                            <xsl:when test="substring(.,1,3) = substring(../lpage,1,3)">
                            	<xsl:value-of select="substring(../lpage,4,4)"/>
                            </xsl:when>
                            <xsl:when test="substring(.,1,2) = substring(../lpage,1,2)">
                            	<xsl:value-of select="substring(../lpage,3,5)"/>
                            </xsl:when>                            
                            <xsl:when test="substring(.,1,1) = substring(../lpage,1,1)">
                            	<xsl:value-of select="substring(../lpage,2,6)"/>
                            </xsl:when>
                            <xsl:otherwise>
                            	<xsl:value-of select="../lpage"/>
                            </xsl:otherwise>
                        </xsl:choose>
                    </xsl:when>
                    <xsl:when test="string-length(.) = 6">
                         <xsl:choose>
                            <xsl:when test="string-length(.) &lt; string-length(../lpage)">
                                <xsl:value-of select="../lpage"/>
                            </xsl:when>
                            <xsl:when test="substring(.,1,5) = substring(../lpage,1,5)">
                            	<xsl:value-of select="substring(../lpage,6,1)"/>
                            </xsl:when>
                            <xsl:when test="substring(.,1,4) = substring(../lpage,1,4)">
                            	<xsl:value-of select="substring(../lpage,5,2)"/>
                            </xsl:when>
                            <xsl:when test="substring(.,1,3) = substring(../lpage,1,3)">
                            	<xsl:value-of select="substring(../lpage,4,3)"/>
                            </xsl:when>
                            <xsl:when test="substring(.,1,2) = substring(../lpage,1,2)">
                            	<xsl:value-of select="substring(../lpage,3,4)"/>
                            </xsl:when>
                            <xsl:when test="substring(.,1,1) = substring(../lpage,1,1)">
                            	<xsl:value-of select="substring(../lpage,2,5)"/>
                            </xsl:when>
                            <xsl:otherwise>
                            	<xsl:value-of select="../lpage"/>
                            </xsl:otherwise>
                        </xsl:choose>
                    </xsl:when>
                    <xsl:when test="string-length(.) = 5">
                         <xsl:choose>
                            <xsl:when test="string-length(.) &lt; string-length(../lpage)">
                                <xsl:value-of select="../lpage"/>
                            </xsl:when>
                            <xsl:when test="substring(.,1,4) = substring(../lpage,1,4)">
                            	<xsl:value-of select="substring(../lpage,5,1)"/>
                            </xsl:when>
                            <xsl:when test="substring(.,1,3) = substring(../lpage,1,3)">
                            	<xsl:value-of select="substring(../lpage,4,2)"/>
                            </xsl:when>
                            <xsl:when test="substring(.,1,2) = substring(../lpage,1,2)">
                            	<xsl:value-of select="substring(../lpage,3,3)"/>
                            </xsl:when>
                            <xsl:when test="substring(.,1,1) = substring(../lpage,1,1)">
                            	<xsl:value-of select="substring(../lpage,2,4)"/>
                            </xsl:when>
                            <xsl:otherwise>
                            	<xsl:value-of select="../lpage"/>
                            </xsl:otherwise>
                        </xsl:choose>
                    </xsl:when>
                    <xsl:when test="string-length(.) = 4">
                         <xsl:choose>
                            <xsl:when test="string-length(.) &lt; string-length(../lpage)">
                                <xsl:value-of select="../lpage"/>
                            </xsl:when>
                            <xsl:when test="substring(.,1,3) = substring(../lpage,1,3)">
                            	<xsl:value-of select="substring(../lpage,4,1)"/>
                            </xsl:when>
                            <xsl:when test="substring(.,1,2) = substring(../lpage,1,2)">
                            	<xsl:value-of select="substring(../lpage,3,2)"/>
                            </xsl:when>
                            <xsl:when test="substring(.,1,1) = substring(../lpage,1,1)">
                            	<xsl:value-of select="substring(../lpage,2,3)"/>
                            </xsl:when>
                            <xsl:otherwise>
                            	<xsl:value-of select="../lpage"/>
                            </xsl:otherwise>
                        </xsl:choose>
                    </xsl:when>
                    <xsl:when test="string-length(.) = 3">
                         <xsl:choose>
                            <xsl:when test="string-length(.) &lt; string-length(../lpage)">
                                <xsl:value-of select="../lpage"/>
                            </xsl:when>
                            <xsl:when test="substring(.,1,2) = substring(../lpage,1,2)">
                            	<xsl:value-of select="substring(../lpage,3,1)"/>
                            </xsl:when>                           
                            <xsl:when test="substring(.,1,1) = substring(../lpage,1,1)">
                            	<xsl:value-of select="substring(../lpage,2,2)"/>
                            </xsl:when>
                            <xsl:otherwise>
                            	<xsl:value-of select="../lpage"/>
                            </xsl:otherwise>
                        </xsl:choose>
                    </xsl:when>
                    <xsl:when test="string-length(.) = 2">
                        <xsl:choose>
                            <xsl:when test="string-length(.) &lt; string-length(../lpage)">
                                <xsl:value-of select="../lpage"/>
                            </xsl:when>
                            <xsl:when test="substring(.,1,1) = substring(../lpage,1,1)">
                            	<xsl:value-of select="substring(../lpage,2,1)"/>
                            </xsl:when>
                            <xsl:otherwise>
                            	<xsl:value-of select="../lpage"/>
                            </xsl:otherwise>
                        </xsl:choose>
                    </xsl:when>
                    <xsl:when test="string-length(.) = 1">
                        <xsl:value-of select="../lpage"/>
                    </xsl:when>
                </xsl:choose>
                
                
                    <xsl:text>.</xsl:text>
                
            </xsl:when>
            <xsl:otherwise>
            	
                <xsl:text>.</xsl:text>
				
            </xsl:otherwise>
        </xsl:choose>
	</xsl:template>
    
    <xsl:template match="fpage" mode="vancouver">
		<xsl:if test="not(../@citation-type='book')">
            <xsl:if test="../volume">
                <xsl:text>: </xsl:text>
            </xsl:if>
        </xsl:if>
        
        <xsl:value-of select="."/>
        <xsl:choose>
            <xsl:when test="following-sibling::lpage">
                <xsl:text>-</xsl:text>
                <xsl:choose>
                    <xsl:when test="string-length(.) = 7">
                         <xsl:choose>
                            <xsl:when test="string-length(.) &lt; string-length(../lpage)">
                                <xsl:value-of select="../lpage"/>
                            </xsl:when>
                            <xsl:when test="substring(.,1,6) = substring(../lpage,1,6)">
                            	<xsl:value-of select="substring(../lpage,7,1)"/>
                            </xsl:when>
                            <xsl:when test="substring(.,1,5) = substring(../lpage,1,5)">
                            	<xsl:value-of select="substring(../lpage,6,2)"/>
                            </xsl:when>
                            <xsl:when test="substring(.,1,4) = substring(../lpage,1,4)">
                            	<xsl:value-of select="substring(../lpage,5,3)"/>
                            </xsl:when>
                            <xsl:when test="substring(.,1,3) = substring(../lpage,1,3)">
                            	<xsl:value-of select="substring(../lpage,4,4)"/>
                            </xsl:when>
                            <xsl:when test="substring(.,1,2) = substring(../lpage,1,2)">
                            	<xsl:value-of select="substring(../lpage,3,5)"/>
                            </xsl:when>                            
                            <xsl:when test="substring(.,1,1) = substring(../lpage,1,1)">
                            	<xsl:value-of select="substring(../lpage,2,6)"/>
                            </xsl:when>
                            <xsl:otherwise>
                            	<xsl:value-of select="../lpage"/>
                            </xsl:otherwise>
                        </xsl:choose>
                    </xsl:when>
                    <xsl:when test="string-length(.) = 6">
                         <xsl:choose>
                            <xsl:when test="string-length(.) &lt; string-length(../lpage)">
                                <xsl:value-of select="../lpage"/>
                            </xsl:when>
                            <xsl:when test="substring(.,1,5) = substring(../lpage,1,5)">
                            	<xsl:value-of select="substring(../lpage,6,1)"/>
                            </xsl:when>
                            <xsl:when test="substring(.,1,4) = substring(../lpage,1,4)">
                            	<xsl:value-of select="substring(../lpage,5,2)"/>
                            </xsl:when>
                            <xsl:when test="substring(.,1,3) = substring(../lpage,1,3)">
                            	<xsl:value-of select="substring(../lpage,4,3)"/>
                            </xsl:when>
                            <xsl:when test="substring(.,1,2) = substring(../lpage,1,2)">
                            	<xsl:value-of select="substring(../lpage,3,4)"/>
                            </xsl:when>
                            <xsl:when test="substring(.,1,1) = substring(../lpage,1,1)">
                            	<xsl:value-of select="substring(../lpage,2,5)"/>
                            </xsl:when>
                            <xsl:otherwise>
                            	<xsl:value-of select="../lpage"/>
                            </xsl:otherwise>
                        </xsl:choose>
                    </xsl:when>
                    <xsl:when test="string-length(.) = 5">
                         <xsl:choose>
                            <xsl:when test="string-length(.) &lt; string-length(../lpage)">
                                <xsl:value-of select="../lpage"/>
                            </xsl:when>
                            <xsl:when test="substring(.,1,4) = substring(../lpage,1,4)">
                            	<xsl:value-of select="substring(../lpage,5,1)"/>
                            </xsl:when>
                            <xsl:when test="substring(.,1,3) = substring(../lpage,1,3)">
                            	<xsl:value-of select="substring(../lpage,4,2)"/>
                            </xsl:when>
                            <xsl:when test="substring(.,1,2) = substring(../lpage,1,2)">
                            	<xsl:value-of select="substring(../lpage,3,3)"/>
                            </xsl:when>
                            <xsl:when test="substring(.,1,1) = substring(../lpage,1,1)">
                            	<xsl:value-of select="substring(../lpage,2,4)"/>
                            </xsl:when>
                            <xsl:otherwise>
                            	<xsl:value-of select="../lpage"/>
                            </xsl:otherwise>
                        </xsl:choose>
                    </xsl:when>
                    <xsl:when test="string-length(.) = 4">
                         <xsl:choose>
                            <xsl:when test="string-length(.) &lt; string-length(../lpage)">
                                <xsl:value-of select="../lpage"/>
                            </xsl:when>
                            <xsl:when test="substring(.,1,3) = substring(../lpage,1,3)">
                            	<xsl:value-of select="substring(../lpage,4,1)"/>
                            </xsl:when>
                            <xsl:when test="substring(.,1,2) = substring(../lpage,1,2)">
                            	<xsl:value-of select="substring(../lpage,3,2)"/>
                            </xsl:when>
                            <xsl:when test="substring(.,1,1) = substring(../lpage,1,1)">
                            	<xsl:value-of select="substring(../lpage,2,3)"/>
                            </xsl:when>
                            <xsl:otherwise>
                            	<xsl:value-of select="../lpage"/>
                            </xsl:otherwise>
                        </xsl:choose>
                    </xsl:when>
                    <xsl:when test="string-length(.) = 3">
                         <xsl:choose>
                            <xsl:when test="string-length(.) &lt; string-length(../lpage)">
                                <xsl:value-of select="../lpage"/>
                            </xsl:when>
                            <xsl:when test="substring(.,1,2) = substring(../lpage,1,2)">
                            	<xsl:value-of select="substring(../lpage,3,1)"/>
                            </xsl:when>                           
                            <xsl:when test="substring(.,1,1) = substring(../lpage,1,1)">
                            	<xsl:value-of select="substring(../lpage,2,2)"/>
                            </xsl:when>
                            <xsl:otherwise>
                            	<xsl:value-of select="../lpage"/>
                            </xsl:otherwise>
                        </xsl:choose>
                    </xsl:when>
                    <xsl:when test="string-length(.) = 2">
                        <xsl:choose>
                            <xsl:when test="string-length(.) &lt; string-length(../lpage)">
                                <xsl:value-of select="../lpage"/>
                            </xsl:when>
                            <xsl:when test="substring(.,1,1) = substring(../lpage,1,1)">
                            	<xsl:value-of select="substring(../lpage,2,1)"/>
                            </xsl:when>
                            <xsl:otherwise>
                            	<xsl:value-of select="../lpage"/>
                            </xsl:otherwise>
                        </xsl:choose>
                    </xsl:when>
                    <xsl:when test="string-length(.) = 1">
                        <xsl:value-of select="../lpage"/>
                    </xsl:when>
                </xsl:choose>
                
                
                    <xsl:text>.</xsl:text>
                
            </xsl:when>
            <xsl:otherwise>
            	
                <xsl:text>.</xsl:text>
				
            </xsl:otherwise>
        </xsl:choose>
	</xsl:template>

	<xsl:template match="fpage" mode="none">
		<xsl:variable name="fpgct" select="count(../fpage)"/>
		<xsl:variable name="lpgct" select="count(../lpage)"/>
		<xsl:variable name="hermano" select="name(following-sibling::node())"/>		
		<xsl:choose>
			<xsl:when test="preceding-sibling::fpage">
				<xsl:choose>
					<xsl:when test="following-sibling::fpage">
						<xsl:text> </xsl:text>
						<xsl:apply-templates/>

						<xsl:if test="$hermano='lpage'">
							<xsl:text>-</xsl:text>
							<xsl:apply-templates select="following-sibling::lpage[1]" mode="none"/>
						</xsl:if>
						<xsl:text>,</xsl:text>
					</xsl:when>
					<xsl:otherwise>
						<xsl:text> </xsl:text>
						<xsl:apply-templates/>
						<xsl:if test="$hermano='lpage'">
							<xsl:text>-</xsl:text>
							<xsl:apply-templates select="following-sibling::lpage[1]" mode="none"/>
						</xsl:if>
						<xsl:text>.</xsl:text>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:when>
			<xsl:otherwise>
				<xsl:text>: </xsl:text>
				<xsl:apply-templates/>
				<xsl:choose>
					<xsl:when test="$hermano='lpage'">
						<xsl:text>-</xsl:text>
						<xsl:apply-templates select="following-sibling::lpage[1]" mode="write"/>
						<xsl:text>.</xsl:text>
					</xsl:when>
					<xsl:when test="$hermano='fpage'">
						<xsl:text>,</xsl:text>
					</xsl:when>
					<xsl:otherwise>
						<xsl:text>.</xsl:text>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:otherwise>
		</xsl:choose>


	</xsl:template>

	<xsl:template match="lpage" mode="none"/>
    
    <xsl:template match="lpage" mode="acs"/>
    
    <xsl:template match="lpage" mode="ieee"/>
    
    <xsl:template match="lpage" mode="ieee-explicit">
    	<xsl:text>-</xsl:text>
    	<xsl:apply-templates/>
    </xsl:template>
    
    <xsl:template match="lpage" mode="vancouver"/>

	
	<xsl:template match="lpage" mode="write">
		<xsl:apply-templates/>
	</xsl:template>

	<xsl:template match="gov" mode="none">
		<xsl:choose>
			<xsl:when test="../trans-title">
				<xsl:apply-templates/>
			</xsl:when>

			<xsl:otherwise>
				<xsl:apply-templates/>
				<xsl:text>. </xsl:text>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

	<xsl:template match="patent" mode="none">
		<xsl:apply-templates/>
		<xsl:text>. </xsl:text>
	</xsl:template>
	
    <xsl:template match="patent" mode="vancouver">
		<xsl:apply-templates/>
		<xsl:text>, </xsl:text>
	</xsl:template>
    
    <xsl:template match="patent" mode="acs">
		<xsl:apply-templates/>
		<xsl:text>, </xsl:text>
	</xsl:template>
    
    <xsl:template match="pub-id" mode="acs">
        <xsl:choose>
			<xsl:when test="@pub-id-type='doi'">
				<xsl:text>[</xsl:text>
<a target="_blank"><xsl:attribute name="href"><xsl:text>http://dx.doi.org/</xsl:text><xsl:apply-templates/></xsl:attribute><xsl:text>http://dx.doi.org/</xsl:text><xsl:apply-templates/></a>
		<xsl:text>] </xsl:text>
			</xsl:when>
			
			<xsl:when test="@pub-id-type='pmcid'">
				<xsl:text>[PMCID: </xsl:text>
<a target="_blank"><xsl:attribute name="href"><xsl:text>http://www.ncbi.nlm.nih.gov/pmc/articles/</xsl:text><xsl:apply-templates/></xsl:attribute><xsl:apply-templates/></a>
		<xsl:text>] </xsl:text>
			</xsl:when>
            
			<xsl:when test="@pub-id-type='pmid'">
				<xsl:text>[PMID: </xsl:text>
<a target="_blank"><xsl:attribute name="href"><xsl:text>http://www.ncbi.nlm.nih.gov/pubmed/</xsl:text><xsl:apply-templates/></xsl:attribute><xsl:apply-templates/></a>
		<xsl:text>] </xsl:text>
			</xsl:when>
		</xsl:choose>
	</xsl:template>
	
    <xsl:template match="pub-id" mode="apa">
        <xsl:choose>
			<xsl:when test="@pub-id-type='doi'">
				<xsl:text>[</xsl:text>
<a target="_blank"><xsl:attribute name="href"><xsl:text>http://dx.doi.org/</xsl:text><xsl:apply-templates/></xsl:attribute><xsl:text>http://dx.doi.org/</xsl:text><xsl:apply-templates/></a>
		<xsl:text>] </xsl:text>
			</xsl:when>
			
			<xsl:when test="@pub-id-type='pmcid'">
				<xsl:text>[PMCID: </xsl:text>
<a target="_blank"><xsl:attribute name="href"><xsl:text>http://www.ncbi.nlm.nih.gov/pmc/articles/</xsl:text><xsl:apply-templates/></xsl:attribute><xsl:apply-templates/></a>
		<xsl:text>] </xsl:text>
			</xsl:when>
            
			<xsl:when test="@pub-id-type='pmid'">
				<xsl:text>[PMID: </xsl:text>
<a target="_blank"><xsl:attribute name="href"><xsl:text>http://www.ncbi.nlm.nih.gov/pubmed/</xsl:text><xsl:apply-templates/></xsl:attribute><xsl:apply-templates/></a>
		<xsl:text>] </xsl:text>
			</xsl:when>
		</xsl:choose>
	</xsl:template>
    
    <xsl:template match="pub-id" mode="harvard">
        <xsl:choose>
			<xsl:when test="@pub-id-type='doi'">
				<xsl:text>[</xsl:text>
<a target="_blank"><xsl:attribute name="href"><xsl:text>http://dx.doi.org/</xsl:text><xsl:apply-templates/></xsl:attribute><xsl:text>http://dx.doi.org/</xsl:text><xsl:apply-templates/></a>
		<xsl:text>] </xsl:text>
			</xsl:when>
			
			<xsl:when test="@pub-id-type='pmcid'">
				<xsl:text>[PMCID: </xsl:text>
<a target="_blank"><xsl:attribute name="href"><xsl:text>http://www.ncbi.nlm.nih.gov/pmc/articles/</xsl:text><xsl:apply-templates/></xsl:attribute><xsl:apply-templates/></a>
		<xsl:text>] </xsl:text>
			</xsl:when>
            
			<xsl:when test="@pub-id-type='pmid'">
				<xsl:text>[PMID: </xsl:text>
<a target="_blank"><xsl:attribute name="href"><xsl:text>http://www.ncbi.nlm.nih.gov/pubmed/</xsl:text><xsl:apply-templates/></xsl:attribute><xsl:apply-templates/></a>
		<xsl:text>] </xsl:text>
			</xsl:when>
		</xsl:choose>
	</xsl:template>
    
    <xsl:template match="pub-id" mode="ieee">
        <xsl:choose>
			<xsl:when test="@pub-id-type='doi'">
				<xsl:text>[</xsl:text>
<a target="_blank"><xsl:attribute name="href"><xsl:text>http://dx.doi.org/</xsl:text><xsl:apply-templates/></xsl:attribute><xsl:text>http://dx.doi.org/</xsl:text><xsl:apply-templates/></a>
		<xsl:text>] </xsl:text>
			</xsl:when>
			
			<xsl:when test="@pub-id-type='pmcid'">
				<xsl:text>[PMCID: </xsl:text>
<a target="_blank"><xsl:attribute name="href"><xsl:text>http://www.ncbi.nlm.nih.gov/pmc/articles/</xsl:text><xsl:apply-templates/></xsl:attribute><xsl:apply-templates/></a>
		<xsl:text>] </xsl:text>
			</xsl:when>
            
			<xsl:when test="@pub-id-type='pmid'">
				<xsl:text>[PMID: </xsl:text>
<a target="_blank"><xsl:attribute name="href"><xsl:text>http://www.ncbi.nlm.nih.gov/pubmed/</xsl:text><xsl:apply-templates/></xsl:attribute><xsl:apply-templates/></a>
		<xsl:text>] </xsl:text>
			</xsl:when>
		</xsl:choose>
	</xsl:template>
    
    <xsl:template match="pub-id" mode="vancouver">
        <xsl:choose>
			<xsl:when test="@pub-id-type='doi'">
				<xsl:text>[</xsl:text>
<a target="_blank"><xsl:attribute name="href"><xsl:text>http://dx.doi.org/</xsl:text><xsl:apply-templates/></xsl:attribute><xsl:text>http://dx.doi.org/</xsl:text><xsl:apply-templates/></a>
		<xsl:text>] </xsl:text>
			</xsl:when>
			
			<xsl:when test="@pub-id-type='pmcid'">
				<xsl:text>[PMCID: </xsl:text>
<a target="_blank"><xsl:attribute name="href"><xsl:text>http://www.ncbi.nlm.nih.gov/pmc/articles/</xsl:text><xsl:apply-templates/></xsl:attribute><xsl:apply-templates/></a>
		<xsl:text>] </xsl:text>
			</xsl:when>
            
			<xsl:when test="@pub-id-type='pmid'">
				<xsl:text>[PMID: </xsl:text>
<a target="_blank"><xsl:attribute name="href"><xsl:text>http://www.ncbi.nlm.nih.gov/pubmed/</xsl:text><xsl:apply-templates/></xsl:attribute><xsl:apply-templates/></a>
		<xsl:text>] </xsl:text>
			</xsl:when>
		</xsl:choose>
	</xsl:template>
    
	<xsl:template match="pub-id" mode="none">
        <xsl:choose>
			<xsl:when test="@pub-id-type='doi'">
				<xsl:text>[</xsl:text>
<a target="_blank"><xsl:attribute name="href"><xsl:text>http://dx.doi.org/</xsl:text><xsl:apply-templates/></xsl:attribute><xsl:text>http://dx.doi.org/</xsl:text><xsl:apply-templates/></a>
		<xsl:text>] </xsl:text>
			</xsl:when>
			
			<xsl:when test="@pub-id-type='pmcid'">
				<xsl:text>[PMCID: </xsl:text>
<a target="_blank"><xsl:attribute name="href"><xsl:text>http://www.ncbi.nlm.nih.gov/pmc/articles/</xsl:text><xsl:apply-templates/></xsl:attribute><xsl:apply-templates/></a>
		<xsl:text>] </xsl:text>
			</xsl:when>
            
			<xsl:when test="@pub-id-type='pmid'">
				<xsl:text>[PMID: </xsl:text>
<a target="_blank"><xsl:attribute name="href"><xsl:text>http://www.ncbi.nlm.nih.gov/pubmed/</xsl:text><xsl:apply-templates/></xsl:attribute><xsl:apply-templates/></a>
		<xsl:text>] </xsl:text>
			</xsl:when>
		</xsl:choose>
	</xsl:template>
	
	<xsl:template match="comment" mode="none">
		<xsl:text> </xsl:text>
		<xsl:apply-templates/>
	</xsl:template>

	<xsl:template match="comment" mode="vancouver">
		<xsl:text> </xsl:text>
		<xsl:apply-templates/>
	</xsl:template>
    
    <xsl:template match="comment" mode="acs">
		<xsl:text> </xsl:text>
		<xsl:apply-templates/>
	</xsl:template>
    
    <xsl:template match="comment" mode="ieee">
		<xsl:text> </xsl:text>
		<xsl:apply-templates/>
	</xsl:template>
    
    <xsl:template match="comment" mode="apa">
		<xsl:text> </xsl:text>
		<xsl:apply-templates/>
	</xsl:template>
    
    <xsl:template match="comment" mode="harvard">
		<xsl:text> </xsl:text>
		<xsl:apply-templates/>
	</xsl:template>


	<!-- ============================================================= -->
	<!--  57. "CITATION-TAG-ENDS"                                      -->
	<!-- ============================================================= -->


	<xsl:template name="citation-tag-ends">

		<xsl:apply-templates select="series" mode="citation"/>

		<!-- If language is not English -->
		<!-- XX review logic -->
		<xsl:if test="article-title[@xml:lang!='en']
               or article-title[@xml:lang!='EN']">

			<xsl:call-template name="language">
				<xsl:with-param name="lang" select="article-title/@xml:lang"/>
			</xsl:call-template>
		</xsl:if>

		<xsl:if test="source[@xml:lang!='en']
              or source[@xml:lang!='EN']">

			<xsl:call-template name="language">
				<xsl:with-param name="lang" select="source/@xml:lang"/>
			</xsl:call-template>
		</xsl:if>

		<xsl:apply-templates select="comment" mode="citation"/>

		<xsl:apply-templates select="annotation" mode="citation"/>

	</xsl:template>


</xsl:transform>
