views:

15

answers:

1

In XSLT 1.0 (using Xalan), outputting the result of:

<xsl:variable name="source0" select="number(num3)"/>
<xsl:value-of select="$source0"/>

was the number spelled out as 2011234. But in XSLT 2.0 (using Saxon), it shows up as 2.011234E6. I want it to always display as 2011234 in the Saxon/2.0 case.

Is there a way to set the default picture string for whenever it outputs a number?

I saw decimal-format, but that just affects picture strings, it doesn't set number formatting. I can't just throw format-number everywhere since then I'd have to check datatypes everywhere and... it would be a mess.

+1  A: 

There is no way to express in XSLT 2.0 (or XSLT 1.0) that every time a number value is output it must be in a "default" format, without ussing fn:format-number() or xsl:decimal-format or op:cast or built-in type constructors. The only way that every number will be consider of some specific type is that a schema has been declared for the input (so it's a PSVI) and you run the transformation with schema-awere processor.

Alejandro
Thanks for the answer...Wow, that seems crazy. There is a default conversion, obviously, so why not make it possible to adjust that default conversion? What a nuisance. So it requires format-number's showing up all over the place... and now I discover that format-number has serious issues... but that's a different question...
taotree
@taotree: I think that to declare a "default" number format it would be a feature, but I don't think it would be a much desired one like first class function, items pattren matching or nested sequence, as example.
Alejandro
Actually, it doesn't matter. The number formatting support is minimal, the default format that switches to scientific at 7 digits... the supporting features are insufficient to make settable default formatting all that meaningful anyway.
taotree