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...
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I wonder if these different results(Saxon-HE 9.4.0.4J) are also covered by the spec (I skimmed it but w/o conclusion):
format-number(xs:double(0), '#.#') ==> ""
format-number(xs:integer(0), '#.#') ==> "0"
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Both these give ".0" on 9.7. There's been a lot of work on edge cases of format-number() in both the spec and the product since this thread was started. You're pointing at the 2.0 spec, but for edge cases it would be better to consult Functions and Operators 3.1.
Hi,
I wonder if these different results(Saxon-HE 9.4.0.4J) are also covered by the spec https://www.w3.org/TR/xslt20/#function-format-number (I skimmed it but w/o conclusion):
format-number(xs:double(0), '#.#') ==> ""
format-number(xs:integer(0), '#.#') ==> "0"
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>
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####'
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...
Hi,
I wonder if these different results(Saxon-HE 9.4.0.4J) are also covered by the spec (I skimmed it but w/o conclusion):
format-number(xs:double(0), '#.#') ==> ""
format-number(xs:integer(0), '#.#') ==> "0"
Both these give ".0" on 9.7. There's been a lot of work on edge cases of format-number() in both the spec and the product since this thread was started. You're pointing at the 2.0 spec, but for edge cases it would be better to consult Functions and Operators 3.1.
Please also note this forum is no longer active.
You've made my day! 8-)