Altova Mailing List Archives


[xsl] format-number in XSLT 1.0

From: Jack Matheson <jack@-------------->
To:
Date: 1/25/2005 5:14:00 PM
I created a small example stylesheet to see how positive and negative 
format patterns are used, but something doesn't make sense to me.



Given the following stylesheet:



<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

 <xsl:output method="text"/>

 <xsl:template match="/">

    pos: <xsl:value-of select="format-number(31415, '##,##.0;0000')"/>

    neg: <xsl:value-of select="format-number(-31415, '##,##.0;0000')"/>

 </xsl:template>

</xsl:stylesheet>



Xalan (bundled with my Java distribution) produces:
    pos: 3,14,15.0
    neg: -3,14,15.0

Saxon (8.2) produces
    pos: 3,14,15.0
    neg: 31415

Can anyone tell me which is correct? In Kay's XSLT 1.0 reference, I 
found this:



"If there is an explicit negative subpattern, it serves only to specify 
the negative prefix and suffix; the number of digits, minimal digits, 
and other characteristics are all the same as the positive pattern."



Doesn't this mean that the negative pattern should be identical to the 
positive pattern with a "-" prefix?



Any clarification is greatly appreciated =)

Disclaimer

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.