Project

Profile

Help

Bug candidate: format-number(0,'#.####')

Added by Anonymous almost 15 years ago

Legacy ID: #7412650 Legacy Poster: penguish (penguish)

Saxon-B 9.1.0.6 using format-number on zero results in an empty string. sample xml: <numbers> <test id="1">1.3</test> <test id="4">0.0</test> <test id="5">0</test> </numbers> XSLT test case: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs" version="2.0"> <xsl:output method="text"/> <xsl:template match="numbers"> <xsl:apply-templates/> </xsl:template> <xsl:template match="test"> <xsl:value-of select="concat('Original: ',text())"/> Format with #.##### '<xsl:value-of select="format-number(xs:double(.), '#.#####')"/>' </xsl:template> </xsl:stylesheet>


Replies (2)

RE: Bug candidate: format-number(0,'#.####') - Added by Anonymous almost 15 years ago

Legacy ID: #7412732 Legacy Poster: Michael Kay (mhkay)

This result seems to be in accordance with the spec. Why do you think it is wrong? If you want at least one digit in the result, you should specify '0.######' or '0.0#####' or perhaps #.0####'

RE: Bug candidate: format-number(0,'#.####') - Added by Anonymous almost 15 years ago

Legacy ID: #7412904 Legacy Poster: penguish (penguish)

Aha. Another case of RTFM, sorry for the noise. I expected at least one digit in there, to reflect the fact that it was a number after all; it seems perverse to format a number and end up with nothing at all. I'll have to re-read your books...

    (1-2/2)

    Please register to reply