[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Difference in Xalan & Saxon for format-number fun
XSLT 1.0 refers to Java JDK 1.1 for the specification of format-number. Unfortunately the JDK 1.1 specification (which is quite hard to find nowadays) is very incomplete. One thing it doesn't say, but which later versions of the JDK document do say, is that many aspects of the negative sub-pattern are ignored: for example, grouping separators are taken from the positive subpattern even if the number is negative. So an XSLT implementation that's built on top of the JDK implementation is likely to have this "feature", while an implementation that's written to the JDK 1.1 specification probably won't. The XSLT 2.0 spec doesn't rely on the JDK any more, it has a free-standing description of the function, and we decided not to carry over this JDK bug. I think the result you are getting from Saxon is consistent with the XSLT 2.0 specification. What do you mean when you say you are losing the formatting - what output did you expect? If you want a grouping separator for negative numbers, you must include it in the negative sub-picture. A correct XSLT 1.0 implementation should do what JDK 1.1 says, which is rather different from what JDK 1.1 (let alone any later JDK) does. Michael Kay > -----Original Message----- > From: Bhupendra Singh [mailto:skbhupendra@xxxxxxxxxxx] > Sent: 17 November 2004 23:32 > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: Difference in Xalan & Saxon for format-number function > > Hi, > I have a template to format a decimal-string(for both > +ve and -ve numbers) > Postive numbers should be transformed as it is but > -ve number should be wrapped in (). > > This is the XSL code. > > <xsl:template name="formatCurrency"> > <xsl:param name = "stCurrency" /> > <xsl:variable name="formatedCurrency"> > <xsl:choose> > <xsl:when test="starts-with($stCurrency,'-')"> > <xsl:value-of select="format-number > ($stCurrency, '#,##0.00;(#0.00)')"/> > </xsl:when> > <xsl:otherwise> > <xsl:value-of select="format-number > ($stCurrency, '#,##0.00')"/> > </xsl:otherwise> > </xsl:choose> > </xsl:variable> > <xsl:value-of select="$formatedCurrency"/> > </xsl:template> > > Both are working fine for +ve numbers but -ve ones > have issues. > > For a value of -263504.720000, I am getting > (263,504.72 in Xalan and (263504.72) in saxon8. > > Saxon8 is working fine with the braces but looses the > formating and Xalan retains the formatting but looses > the closing ). > > Any clues, what is the cause and what will be the > correct solution so that it works in both. > > Thanks in advance. > Bhupendra. > > > > > > ______________________________________________________________ > __________ > Yahoo! India Matrimony: Find your life partner online > Go to: http://yahoo.shaadi.com/india-matrimony
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|