<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet id="1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:output method="xml" omit-xml-declaration="yes" encoding="utf-8" />
  <!-- periodica.xsl, (c) Gradusoft Ltd. March, 2011. -->
  <xsl:param name="periodica" select="'undefined'" />
  <xsl:param name="paramtipus" select="'undefined'" />
  <xsl:param name="parameter" select="'undefined'" />
  <xsl:param name="browser" select="'undefined'" />
  <xsl:variable name="browser_name">
    <xsl:choose>
      <xsl:when test="$browser = 'undefined'">
        <xsl:value-of select="//ROOT/parameters/@browser" />
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="$browser" />
      </xsl:otherwise>
    </xsl:choose>
  </xsl:variable>
  <xsl:variable name="periodica_name">
    <xsl:choose>
      <xsl:when test="$periodica = 'undefined'">
        <xsl:value-of select="//ROOT/parameters/@periodica" />
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="$periodica" />
      </xsl:otherwise>
    </xsl:choose>
  </xsl:variable>
  <xsl:variable name="paramtipus_name">
    <xsl:choose>
      <xsl:when test="$paramtipus = 'undefined'">
        <xsl:value-of select="//ROOT/parameters/@paramtipus" />
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="$paramtipus" />
      </xsl:otherwise>
    </xsl:choose>
  </xsl:variable>
  <xsl:variable name="parameter_value">
    <xsl:choose>
      <xsl:when test="$parameter = 'undefined'">
        <xsl:value-of select="//ROOT/parameters/@parameter" />
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="$parameter" />
      </xsl:otherwise>
    </xsl:choose>
  </xsl:variable>
  <xsl:template match="/">
    <html>
      <head>
        <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
        <link rel="stylesheet" href="periodica.css" type="text/css" />
        <script type="text/javascript" src="periodica.js">
          var x;
        </script>
      </head>
      <body>
          <xsl:choose>
            <xsl:when test="$paramtipus_name = 'periodica' or $paramtipus_name = 'undefined'">
              <xsl:apply-templates select="ROOT" mode="periodica"/>
            </xsl:when>
            <xsl:when test="$paramtipus_name = 'volumes'">
              <xsl:apply-templates select="ROOT" mode="volumes"/>
            </xsl:when>
            <xsl:when test="$paramtipus_name = 'publications'">
              <xsl:apply-templates select="ROOT" mode="publications"/>
            </xsl:when>
            <xsl:when test="$paramtipus_name = 'publication'">
              <xsl:call-template name="publ_id" >
                <xsl:with-param name="paper_id" select="$parameter_value" />
              </xsl:call-template>
            </xsl:when>
            <xsl:when test="$paramtipus_name = 'editors'">
              <xsl:apply-templates select="ROOT" mode="editors"/>
            </xsl:when>
            <xsl:when test="$paramtipus_name = 'authors'">
              <xsl:apply-templates select="ROOT" mode="authors"/>
            </xsl:when>
            <xsl:when test="$paramtipus_name = 'editor'">
              <xsl:call-template name="editor" >
                <xsl:with-param name="author_id" select="$parameter_value" />
              </xsl:call-template>
            </xsl:when>
            <xsl:when test="$paramtipus_name = 'author'">
              <xsl:call-template name="author" >
                <xsl:with-param name="author_id" select="$parameter_value" />
              </xsl:call-template>
            </xsl:when>
            <xsl:when test="$paramtipus_name = 'person_data'">
              <xsl:call-template name="person_data" >
                <xsl:with-param name="author_id" select="$parameter_value" />
              </xsl:call-template>
            </xsl:when>
            <xsl:otherwise>
              <p class="publication_head">
                Not implemented selection parameter type 
                <xsl:value-of select="$paramtipus_name" />
              </p>
            </xsl:otherwise>
          </xsl:choose>
      </body>
    </html>
  </xsl:template>
  <xsl:template match="ROOT" mode="periodica">
    <p class="publication_head">
      Publication types in 
      <xsl:value-of select="periodica/name" />
    </p>
    <ul>
      <xsl:for-each select="periodica/publication[not(subtype = preceding-sibling::publication/subtype)]">
        <xsl:sort select="subtype" order="ascending" />
        <xsl:variable name="submtype" select="name" />
        <xsl:variable name="subtype_id" select="subtype" />
        <xsl:variable name="subtype_xml" select="/ROOT/periodica/subtype[id = $subtype_id]" />
        <li>
        <xsl:call-template name="subtype_link">
          <xsl:with-param name="subtype_id" select="$subtype_id" />
          <xsl:with-param name="subtype_text" select="$subtype_xml/description" />
          <xsl:with-param name="year" select="-1" />
        </xsl:call-template>
        </li>
      </xsl:for-each>
    </ul>
  </xsl:template>
  <xsl:template match="ROOT" mode="volumes">
    <xsl:variable name="subtype_xml" select="/ROOT/periodica/subtype[id = $periodica_name]" />
    <xsl:for-each select="periodica/publication[subtype = $periodica_name]">
      <xsl:sort select="year" order="descending" />
      <xsl:variable name="volume" select="name" />
      <xsl:if test="(year != preceding-sibling::publication[1]/year) or (position() = last())">
        <xsl:variable name="control_id" select="year" />
        <xsl:choose>
          <xsl:when test="$browser_name != 'ie'" >
            <a href="periodica.html?periodica={$periodica_name}&amp;paramtipus_ertek=publications&amp;param_ertek={$control_id}">
              <xsl:value-of select="$control_id" />
            </a>
          </xsl:when>
          <xsl:otherwise>
            <a href="javascript:displayResult('{$periodica_name}','publications','{$control_id}')">
              <xsl:value-of select="$control_id" />
            </a>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:if>
    </xsl:for-each>
  </xsl:template>
  <xsl:template match="ROOT" mode="publications">
    <xsl:variable name="subtype_xml" select="/ROOT/periodica/subtype[id = $periodica_name]" />
    <xsl:apply-templates select="$subtype_xml/title/div" mode="copy" />
    <ol>
    <xsl:for-each select="periodica/publication[(subtype = $periodica_name) and ((year = $parameter_value) or ($parameter_value = -1))]">
      <xsl:sort select="concat(year,volume)" order="ascending" />
      <xsl:sort select="./issue" data-type="number" order="ascending" />
      <xsl:sort select="./firstpage" data-type="number" />
      <xsl:variable name="control_id" select="id" />
      <xsl:variable name="issue_id" select="issue" />
      <li value="{$issue_id}">
        <xsl:call-template name="paper_data">
          <xsl:with-param name="paper_id" select="$control_id" />
        </xsl:call-template>
      </li>
    </xsl:for-each>
    </ol>
  </xsl:template>
  <xsl:template name="author">
    <xsl:param name="author_id"/>
    <p class="publication_head">
      Publications of the author<br />
      <xsl:call-template name="author_data" >
        <xsl:with-param name="author_id" select="$parameter_value" />
      </xsl:call-template><br />
      in EJQTDE
    </p>
    <ol>
      <xsl:for-each select="/ROOT/periodica/publication/author[id = $author_id]">
        <xsl:sort select="concat(../year,../volume)" order="ascending" />
        <xsl:sort select="../issue" data-type="number" order="ascending" />
        <xsl:sort select="../firstpage" data-type="number" />
        <li>
          <xsl:call-template name="paper_data" >
            <xsl:with-param name="paper_id" select="../id" />
          </xsl:call-template>
        </li>
      </xsl:for-each>
    </ol>
  </xsl:template>
  <xsl:template name="editor">
    <xsl:param name="author_id" />
    <p class="publication_head">
      Papers communicated by the editor<br />
      <xsl:call-template name="author_data" >
        <xsl:with-param name="author_id" select="$parameter_value" />
      </xsl:call-template><br />
      in EJQTDE
    </p>
    <ol>
      <xsl:for-each select="/ROOT/periodica/publication[editor = $author_id]">
        <xsl:sort select="concat(year,volume)" order="ascending" />
        <xsl:sort select="issue" data-type="number" order="ascending" />
        <xsl:sort select="firstpage" data-type="number" />
        <li>
          <xsl:call-template name="paper_data" >
            <xsl:with-param name="paper_id" select="id" />
          </xsl:call-template>
        </li>
      </xsl:for-each>
    </ol>
  </xsl:template>
  <xsl:template match="ROOT" mode="editors">
    <p class="publication_head">
      List of Editors
    </p>
    <br /><b>Honorary Editors:</b><br />
    <xsl:for-each select="/ROOT/periodica/user[(editor = 'yes') and (honorary = 'yes')]">
      <xsl:sort select="famname" order="ascending" />
      <xsl:sort select="firstname" order="ascending" />
      <xsl:variable name="control_id"  >
        <xsl:value-of select="id" />
      </xsl:variable>
      <xsl:value-of select="'&#160;&#160;&#160;&#160;'" />
      <xsl:call-template name="author_data" >
        <xsl:with-param name="author_id" select="$control_id" />
      </xsl:call-template>
      <xsl:if test="foundingeditor = 'yes'">
        (founding editor)
      </xsl:if>
      <br />
    </xsl:for-each>
    <br /><b>Editors in Chief:</b><br />
    <xsl:for-each select="/ROOT/periodica/user[(chiefeditor = 'yes') and (honorary = 'no')]">
      <xsl:sort select="famname" order="ascending" />
      <xsl:sort select="firstname" order="ascending" />
      <xsl:variable name="control_id"  >
        <xsl:value-of select="id" />
      </xsl:variable>
      <xsl:value-of select="'&#160;&#160;&#160;&#160;'" />
      <xsl:call-template name="author_data" >
        <xsl:with-param name="author_id" select="$control_id" />
      </xsl:call-template>
      <xsl:if test="foundingeditor = 'yes'">
        (founding editor)
      </xsl:if>
      <br />
    </xsl:for-each>
    <br /><b>Technical Editor:</b><br />
    <xsl:for-each select="/ROOT/periodica/user[(techeditor = 'yes') and (honorary = 'no')]">
      <xsl:sort select="famname" order="ascending" />
      <xsl:sort select="firstname" order="ascending" />
      <xsl:variable name="control_id"  >
        <xsl:value-of select="id" />
      </xsl:variable>
      <xsl:value-of select="'&#160;&#160;&#160;&#160;'" />
      <xsl:call-template name="author_data" >
        <xsl:with-param name="author_id" select="$control_id" />
      </xsl:call-template>
      <br />
    </xsl:for-each>
    <br /><b>Associate Editors:</b><br />
    <xsl:for-each select="/ROOT/periodica/user[(techeditor != 'yes') and (chiefeditor != 'yes') and (editor = 'yes') and (honorary = 'no')]">
      <xsl:sort select="famname" order="ascending" />
      <xsl:sort select="firstname" order="ascending" />
      <xsl:variable name="control_id"  >
        <xsl:value-of select="id" />
      </xsl:variable>
      <xsl:value-of select="'&#160;&#160;&#160;&#160;'" />
      <xsl:call-template name="author_data" >
        <xsl:with-param name="author_id" select="$control_id" />
      </xsl:call-template>
      <xsl:if test="foundingeditor = 'yes'">
        (founding editor)
      </xsl:if>
      <br />
    </xsl:for-each>
  </xsl:template>
  <xsl:template match="ROOT" mode="authors">
    <p class="publication_head">
      List of Authors
    </p>
    <xsl:for-each select="/ROOT/periodica/user">
      <xsl:sort select="famname" order="ascending" />
      <xsl:sort select="firstname" order="ascending" />
      <xsl:variable name="control_id"  >
        <xsl:value-of select="id" />
      </xsl:variable>
      <xsl:value-of select="'&#160;&#160;&#160;&#160;'" />
      <xsl:call-template name="author_data" >
        <xsl:with-param name="author_id" select="$control_id" />
      </xsl:call-template>
      <br />
    </xsl:for-each>
  </xsl:template>
  <xsl:template name="publ_id" >
    <xsl:param name="paper_id"/>
    <xsl:variable name="paper_xml" select="/ROOT/periodica/publication[id = $paper_id]" />
    <font size="+1"><b>
      <xsl:value-of select="$paper_xml/title" />
    </b></font><br /><br />
    <xsl:variable name="subtype_id"  >
      <xsl:value-of select="$paper_xml/subtype" />
    </xsl:variable>
    <xsl:variable name="editor_id"  >
      <xsl:value-of select="$paper_xml/editor" />
    </xsl:variable>
    <xsl:variable name="subtype_xml" select="/ROOT/periodica/subtype[id = $subtype_id]" />
    <xsl:for-each select="$paper_xml/author" >
      <xsl:variable name="author_id" select="id" />
      <xsl:call-template name="author_data" >
        <xsl:with-param name="author_id" select="$author_id" />
      </xsl:call-template>
      <br />
    </xsl:for-each>
    <br />
    <xsl:call-template name="subtype_link">
      <xsl:with-param name="subtype_id" select="$subtype_id" />
      <xsl:with-param name="subtype_text" select="$subtype_xml/officialdesc" />
      <xsl:with-param name="year" select="$paper_xml/year" />
    </xsl:call-template>
    <xsl:value-of select="', No. '" />
    <xsl:value-of select="$paper_xml/issue" />
    <xsl:value-of select="' ('" />
    <xsl:value-of select="$paper_xml/year" />
    <xsl:value-of select="'), pp. '" />
    <xsl:value-of select="$paper_xml/firstpage" />
    <xsl:value-of select="'-'" />
    <xsl:value-of select="$paper_xml/lastpage" />
    <xsl:value-of select="'.'" />
    <br /><br />
    <table width="100%">
      <tr><td width="50%">Communicated by&#160;
        <xsl:choose>
          <xsl:when test="$browser_name != 'ie'" >
            <a href="periodica.html?periodica={$subtype_id}&amp;paramtipus_ertek=person_data&amp;param_ertek={$editor_id}">
              <b><xsl:call-template name="author_name">
                <xsl:with-param name="author_id" select="$editor_id" />
              </xsl:call-template></b>
            </a>
          </xsl:when>
          <xsl:otherwise>
            <a href="javascript:displayResult('{$subtype_id}','person_data','{$editor_id}')">
              <b><xsl:call-template name="author_name">
                <xsl:with-param name="author_id" select="$editor_id" />
              </xsl:call-template></b>
            </a>
          </xsl:otherwise>
        </xsl:choose>
      </td><td align="right" width="50%">
        <xsl:if test="$paper_xml/received != '0000-00-00'">
          Received on <xsl:value-of select="$paper_xml/received" /><br />
        </xsl:if>
        Appeared on <xsl:value-of select="$paper_xml/published" />
      </td></tr>
    </table><hr />
    <b>Abstract: </b> <xsl:copy-of select="$paper_xml/abstract/div" />
    <hr />
    <xsl:if test="$paper_xml/pubcomment != ''">
      <xsl:copy-of select="$paper_xml/pubcomment/div" /><hr />
    </xsl:if>
    You can download the full text of this paper in <a href="p{$paper_id}.pdf">PDF</a> format.
  </xsl:template>
  <xsl:template name="paper_data" >
    <xsl:param name="paper_id"/>
    <xsl:variable name="paper_xml" select="/ROOT/periodica/publication[id = $paper_id]" />
    <xsl:variable name="subtype_id"  >
      <xsl:value-of select="$paper_xml/subtype" />
    </xsl:variable>
    <xsl:variable name="subtype_xml" select="/ROOT/periodica/subtype[id = $subtype_id]" />
      <xsl:for-each select="$paper_xml/author" >
        <xsl:variable name="author_id" select="id" />
        <xsl:variable name="author_xml" select="/ROOT/periodica/user[id = $author_id]" />
        <xsl:choose>
          <xsl:when test="position() &gt; 1">
            <xsl:choose>
              <xsl:when test="position() = last()">
                <xsl:value-of select="' and '" />
              </xsl:when>
              <xsl:otherwise>
                <xsl:value-of select="', '" />
              </xsl:otherwise>
            </xsl:choose>
          </xsl:when>
        </xsl:choose>
        <xsl:variable name="control_name"  >
          <xsl:call-template name="author_name" >
            <xsl:with-param name="author_id" select="$author_id" />
          </xsl:call-template>
        </xsl:variable>
        <xsl:choose>
          <xsl:when test="$browser_name != 'ie'" >
            <a href="periodica.html?periodica={$subtype_id}&amp;paramtipus_ertek=person_data&amp;param_ertek={$author_id}">
                <xsl:value-of select="$control_name" />
            </a>
          </xsl:when>
          <xsl:otherwise>
            <a href="javascript:displayResult('{$subtype_id}','person_data','{$author_id}')">
              <xsl:value-of select="$control_name" />
            </a>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:for-each>
      <xsl:value-of select="': '" />
      <xsl:choose>
        <xsl:when test="$browser_name != 'ie'" >
          <a href="periodica.html?periodica={$subtype_id}&amp;paramtipus_ertek=publication&amp;param_ertek={$paper_id}">
            <xsl:value-of select="$paper_xml/title" />
          </a>
        </xsl:when>
        <xsl:otherwise>
          <a href="javascript:displayResult('{$subtype_id}','publication','{$paper_id}')">
            <xsl:value-of select="$paper_xml/title" />
          </a>
        </xsl:otherwise>
      </xsl:choose>
      <xsl:value-of select="', '" />
      <xsl:value-of select="$subtype_xml/officialdesc" />
      <xsl:value-of select="', No. '" />
      <xsl:value-of select="$paper_xml/issue" />
      <xsl:value-of select="' ('" />
      <xsl:value-of select="$paper_xml/year" />
      <xsl:value-of select="'), pp. '" />
      <xsl:value-of select="$paper_xml/firstpage" />
      <xsl:value-of select="'-'" />
      <xsl:value-of select="$paper_xml/lastpage" />
      <xsl:value-of select="'.'" />
  </xsl:template>
  <xsl:template name="author_data" >
    <xsl:param name="author_id"/>
    <xsl:variable name="author_xml" select="/ROOT/periodica/user[id = $author_id]" />
    <xsl:variable name="author_www" select="$author_xml/www" />
    <xsl:choose>
      <xsl:when test="$browser_name != 'ie'" >
        <a href="periodica.html?periodica=1&amp;paramtipus_ertek=person_data&amp;param_ertek={$author_id}">
          <b><xsl:call-template name="author_name" >
            <xsl:with-param name="author_id" select="$author_id" />
          </xsl:call-template></b>
        </a>
      </xsl:when>
      <xsl:otherwise>
        <a href="javascript:displayResult('1','person_data','{$author_id}')">
          <b><xsl:call-template name="author_name" >
            <xsl:with-param name="author_id" select="$author_id" />
          </xsl:call-template></b>
        </a>
      </xsl:otherwise>
    </xsl:choose>
    <xsl:value-of select="', '" />
    <xsl:choose>
      <xsl:when test="$author_www != ''" >
        <a target="_blank" href="{$author_www}">
          <xsl:value-of select="$author_xml/affiliation" />
        </a>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="$author_xml/affiliation" />
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
  <xsl:template name="person_data" >
    <xsl:param name="author_id"/>
    <xsl:variable name="author_xml" select="/ROOT/periodica/user[id = $author_id]" />
    <xsl:variable name="author_email" select="$author_xml/email" />
    <xsl:variable name="author_www" select="$author_xml/www" />
    <p class="publication_head">
      <xsl:value-of select="$author_xml/saluation" />
      <xsl:value-of select="' '" />
      <xsl:call-template name="author_name" >
         <xsl:with-param name="author_id" select="$author_id" />
      </xsl:call-template>
    </p>
    <table border="1" cellpadding="2px"><tr><th align="right">E-mail address:</th><td>
      <a target="_blank" href="mailto:{$author_email}">
        <xsl:value-of select="$author_email" />
      </a>
    </td></tr><tr><th align="right">Affiliation:</th><td>
      <xsl:choose>
        <xsl:when test="$author_www != ''" >
          <a target="_blank" href="{$author_www}">
            <xsl:value-of select="$author_xml/affiliation" />
          </a>
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of select="$author_xml/affiliation" />
        </xsl:otherwise>
      </xsl:choose>
    </td></tr><tr><th align="right">Research area, speciality:</th><td>
      <xsl:copy-of select="$author_xml/speciality/div" />
    </td></tr></table>
    <xsl:for-each select="/ROOT/periodica/publication[editor = $author_id]">
      <xsl:if test="position()=last()">
        <xsl:choose>
          <xsl:when test="$browser_name != 'ie'" >
            <br /><a href="periodica.html?periodica=1&amp;paramtipus_ertek=editor&amp;param_ertek={$author_id}">
              List of papers communicated by this editor in EJQTDE
            </a><br />
          </xsl:when>
          <xsl:otherwise>
            <br /><a href="javascript:displayResult('1','editor','{$author_id}')">
              List of papers communicated by this editor in EJQTDE
            </a><br />
          </xsl:otherwise>
        </xsl:choose>
      </xsl:if>
    </xsl:for-each>    
    <xsl:for-each select="/ROOT/periodica/publication/author[id = $author_id]">
      <xsl:if test="position()=last()">
        <xsl:choose>
          <xsl:when test="$browser_name != 'ie'" >
            <br /><a href="periodica.html?periodica=1&amp;paramtipus_ertek=author&amp;param_ertek={$author_id}">
              List of papers by this author in EJQTDE
            </a><br />
          </xsl:when>
          <xsl:otherwise>
            <br /><a href="javascript:displayResult('1','author','{$author_id}')">
              List of papers by this author in EJQTDE
            </a><br />
          </xsl:otherwise>
        </xsl:choose>
      </xsl:if>
    </xsl:for-each>    
  </xsl:template>
  <xsl:template name="author_name" >
    <xsl:param name="author_id"/>
    <xsl:variable name="author_xml" select="/ROOT/periodica/user[id = $author_id]" />
    <xsl:variable name="author_data"  >
      <xsl:value-of select="$author_xml/famname" />
      <xsl:value-of select="','" />
      <xsl:value-of select="' '" />
      <xsl:value-of select="$author_xml/givname" />
      <xsl:if test="$author_xml/midname != ''" >
        <xsl:value-of select="' '" />
        <xsl:value-of select="$author_xml/midname" />
      </xsl:if>
    </xsl:variable>
    <xsl:value-of select="$author_data" />
  </xsl:template>
  <xsl:template name="subtype_link" >
    <xsl:param name="subtype_id"/>
    <xsl:param name="subtype_text"/>
    <xsl:param name="year"/>
    <xsl:variable name="subtype_xml" select="/ROOT/periodica/subtype[id = $subtype_id]" />
    <xsl:variable name="ayear">
      <xsl:choose>
        <xsl:when test="($subtype_xml/nosepvol = 'yes')">
          <xsl:value-of select="-1" />
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of select="$year" />
        </xsl:otherwise>
      </xsl:choose>
    </xsl:variable>
    <xsl:choose>
      <xsl:when test="($subtype_xml/nosepvol = 'yes') or ($year > 0)">
        <xsl:choose>
          <xsl:when test="$browser_name != 'ie'" >
            <a href="periodica.html?periodica={$subtype_id}&amp;paramtipus_ertek=publications&amp;param_ertek={$ayear}">
              <xsl:value-of select="$subtype_text" />
            </a>
          </xsl:when>
          <xsl:otherwise>
            <a href="javascript:displayResult('{$subtype_id}','publications','{$ayear}')">
              <xsl:value-of select="$subtype_text" />
            </a>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:when>
      <xsl:otherwise>
        <xsl:choose>
          <xsl:when test="$browser_name != 'ie'" >
            <a href="periodica.html?periodica={$subtype_id}&amp;paramtipus_ertek=volumes&amp;param_ertek={$subtype_id}">
              <xsl:value-of select="$subtype_text" />
            </a>
          </xsl:when>
          <xsl:otherwise>
            <a href="javascript:displayResult('{$subtype_id}','volumes','{$subtype_id}')">
              <xsl:value-of select="$subtype_text" />
            </a>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
  <xsl:template match="*" mode="copy">
    <xsl:variable name="out_text" select="text()"/>
    <xsl:variable name="out_attrib" select="@*"/>
    <xsl:copy>
      <xsl:choose>
        <xsl:when test="$out_text = 'YEAR'">
          <xsl:value-of select="$parameter_value" />
        </xsl:when>
        <xsl:otherwise>
          <xsl:copy-of select="$out_attrib"/>
        </xsl:otherwise>
      </xsl:choose>
      <xsl:if test="not($out_text = 'YEAR')">
        <xsl:apply-templates mode="copy" />
      </xsl:if>
    </xsl:copy>
  </xsl:template>
</xsl:stylesheet>
