XSLT and currency

XSLT and currency header image

Just some simple code this time, a minor XSLT function to change values to a nice Currency Value. Like it says, it formats a number (some var names are Dutch, sorry for that):

<xsl:template name="FormatNumber">
  <xsl:param name="str" />
  <xsl:param name="defnadekomma" />
  <xsl:variable name="newvalueS" select="string($str)"/>
  <xsl:value-of name="newvalue">
    <xsl:if test="contains($newvalueS,',')">
      <xsl:select="substring-before($newvalueS, ',')"/>
      <xsl:select="$newvalueS"/>
    </xsl:if>
  <xsl:variable name="nadekomma">
    <xsl:if test="contains($newvalueS,',')">
      <xsl:select="concat(',',substring-after($newvalueS,','))"/>
      <xsl:variable name="nadekommaMax">
    </xsl:if>
    <xsl:if test="string-length($nadekomma)> 3">
      <xsl:select="substring($nadekomma,1, 3)"/>
      <xsl:select="$defnadekomma"/>
    </xsl:if>
    <xsl:if test="string-length($newvalue)> 3">
      <xsl:variable name="newvaluews">
        <xsl:select="substring($newvalue,1,string-length($newvalue)  3)"/>
        <xsl:select="substring($newvalue,string-length($newvalue)  2,3)"/>
        <xsl:select="concat($newvaluews,$nadekommaMax)"/>
        <xsl:select="concat($newvalue, $nadekommaMax)"/>
      </xsl:variable>
    </xsl:if>
  €
  <xsl:variable name="FormatNumber">
  <xsl:variable name="str" select="$prijs"/>
  <xsl:variable name="defnadekomma"select="',-'"/>
</xsl:template>
Loading comments…