dMilan
dMilan

Reputation: 257

How to format number with minus at right side?

How to format number with minus at right side? I have xml:

<Invoice>
<TotalAmount>890.09-</TotalAmount>
</Invoice>


<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"  version="1.0">
  <xsl:decimal-format decimal-separator="," grouping-separator="."/>
  
  <xsl:template match="/Invoice">
   <xsl:value-of select="format-number(TotalAmount, '#.###,00')"/>
  </xsl:template>

</xsl:stylesheet>

I think is ok but I have specific requirement, for negativs minus sign is at right side of number instead left side. How to display number in format: '#.###,00' with minus at right side. Should I read value without minus and after that append minus? Is it better solution?

Upvotes: 0

Views: 525

Answers (1)

Tim C
Tim C

Reputation: 70628

I think removing the minus prior to the format number, and then re-appending it, might be the only way to go

Here is one way you could do that, in a single expression

<xsl:value-of select="concat(format-number(translate(TotalAmount, '-', ''), '#.###,00'), translate(TotalAmount, '01234567890.,', ''))"/>

Upvotes: 2

Related Questions