My problem is that I want to format some numbers in an xml file in a
fixed way, yet one which I can change relatively easily if need be. If
we have the file problem.xml:
<?xml version="1.0" encoding="utf-8"?>
<numbers>
<number>22222.444444</number>
<number>2.5555555</number>
<number>999999.444444</number>
<number>22222.444444</number>
</numbers>
and the file problem.xsl:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="text" />
<xsl:template match="number">
<xsl:variable name="numberFormat" select="l.000" />
<xsl:value-of select='format-number(text(), $numberFormat)' />
</xsl:template>
</xsl:stylesheet>
the output is
$ xsltproc problem.xsl problem.xml
22222
3
999999
22222
when I would have expected to see 3 dps on the numbers.
I keep on having this sort of problem with xsl(t?) - there are a hundred and
one good uses for it, but I end up getting completely bogged down.
Any answers?
NickJ
_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--