Task

Create a function taking a positive integer as its parameter and returning a string containing the Roman numeral representation of that integer. Modern Roman numerals are written by expressing each digit separately, starting with the left most digit and skipping any digit with a value of zero.



In Roman numerals:

 1990 is rendered: 1000=M, 900=CM, 90=XC; resulting in MCMXC
 2008 is written as 2000=MM, 8=VIII; or MMVIII
 1666 uses each Roman symbol in descending order: MDCLXVI


 
<xsl:stylesheet  version="1.0"    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="/data/number">
        <xsl:call-template name="for">
               <xsl:with-param name="stop">13</xsl:with-param>
        	<xsl:with-param name="value"><xsl:value-of select="@value"></xsl:value-of></xsl:with-param>
        </xsl:call-template>
    </xsl:template>
 
    <xsl:template name="for">
      <xsl:param name="start">1</xsl:param>
      <xsl:param name="stop">1</xsl:param>
      <xsl:param name="step">1</xsl:param>
      <xsl:param name="value">1</xsl:param>
      <xsl:text/>
      <xsl:choose>
      <xsl:when test="($value &gt; /data/roman
/numeral[@pos=$start]/@value or $value = /data/roman
/numeral[@pos=$start]/@value) ">
          <xsl:value-of select="/data/roman
/numeral[@pos=$start]/@letter"/>
          <xsl:call-template name="for">
          <xsl:with-param name="stop">
            <xsl:value-of select="$stop"/>
          </xsl:with-param>
          <xsl:with-param name="start">
            <xsl:value-of select="$start"/>
          </xsl:with-param>
          <xsl:with-param name="value">
          	<xsl:value-of select="$value - /data/roman/numeral[@pos=$start]/@value"/>
          </xsl:with-param>
        </xsl:call-template>
      </xsl:when>
      <xsl:otherwise>
        <xsl:if test="$start &lt; $stop">
        <xsl:call-template name="for">
          <xsl:with-param name="stop">
            <xsl:value-of select="$stop"/>
          </xsl:with-param>
          <xsl:with-param name="start">
            <xsl:value-of select="$start + $step"/>
          </xsl:with-param>
          <xsl:with-param name="value">
          	<xsl:value-of select="$value"/>
          </xsl:with-param>
        </xsl:call-template>
        </xsl:if>
      </xsl:otherwise>
      </xsl:choose>
    </xsl:template>
</xsl:stylesheet>
 