|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
formatNumber, comma
Hey guys! Need help on this one...
How can I transform this number 12000 into this --> 12,000.00 in xml?!... M a newbie in xml/xsl. please help thanks! |
|
#2
|
|||
|
|||
|
Use the XSLT1 format-number() function
string format-number(number,format,[decimalformat]) Here is an example: ---------- xml ---------- <?xml version="1.0"?> <root> <number>12000</number> </root> --------- xsl ------------ <?xml version="1.0" encoding="ISO-8859-1" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="html"/> <xsl:template match="/"> <xsl:apply-templates select="//number"/> </xsl:template> <xsl:template match="number"> <xsl:value-of select="format-number(.,'##,###.00')"/> </xsl:template> </xsl:stylesheet> |
|
#3
|
|||
|
|||
|
Howcome, it's not working?!?
|
|
#4
|
||||
|
||||
|
Quote:
In fpmurphy's example above, remove this line from the XSL style sheet: <?xml version="1.0" encoding="ISO-8859-1" ?> And it'll work.
__________________
Hello, old friend... |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > formatNumber, comma |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|