Developer forum

Forum » Templates » XSLT Format-number()

XSLT Format-number()


Reply
Hi all,

I was hoping that some of you would be able to help me out a bit here.
I need to shorten down a number, which I get from an XML document (through datalists), to two decimals, insted of four.

Here's my code in XSLT:
<xsl:for-each select="item">
 <xsl:if test="Row.ColumnName = 'depositum_total' and Row.Value != '' and Row.Value != '0'">
  <xsl:variable name="enhedspris" select="Row.Value" /> 
  <br />Depositum <br />kr. <xsl:value-of select='format-number($enhedspris, "#.00")' /> 
 </xsl:if>
</xsl:for-each>

The result here is NaN.

If replace format-number with just the variable, like this:
<xsl:value-of select='$enhedspris' /> 

then I get e.g. 10304,5900...
So from what I can tell, the variable is set correctly. The issue is somewhere in the format-number. I've tried just about anything that came to my mind, but nothing has worked really...

I hope that one of you guys are able to give me an answer to this :)

Thanks in advance.

Replies

 
Reply
Uhm... Yeah, there is something about .NET not supporting XSL 2.0...

I found a solution to my little issue, by using XPATH 1.0 "substring($enhedspris,1 string-length($enhedspris)-2)" - it works! :)

 
Reply
Yes, it's a pain that MS hasn't support for XSLT/XPATH 2.0

That would be very nice to see in the future.

// Dammark

 

You must be logged in to post in the forum