Skip to content
Albert-Jan Schot
Albert-Jan Schot

· 1 min read

Post

XSLT and currency

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>
Albert-Jan Schot

Albert-Jan Schot

CTO, Microsoft MVP & FastTrack Recognized Solution Architect

I am Albert-Jan Schot, CTO at Blis Digital, Microsoft MVP, and FastTrack Recognized Solution Architect focused on Microsoft 365, Azure, and AI agents. I help teams turn complex Microsoft Cloud challenges into practical architecture decisions and shipped outcomes.

Copilot Studio Microsoft 365 Agent Flows

Zuid Holland, Netherlands

Related Posts