Project

Profile

Help

How to adjust number format?

Added by Anonymous almost 14 years ago

Legacy ID: #8532565 Legacy Poster: Joel Shellman (ikestrel)

I have an integer that Saxon is outputting as: 2.0140565E7 and I want it to output it as 20140565. Is there some way I can tell it to do that?


Replies (3)

Please register to reply

RE: How to adjust number format? - Added by Anonymous almost 14 years ago

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

If that's the output format, then it's not an xs:integer, it's an xs:double. It might be worth investigating why it's an xs:double - perhaps for example you used the number() function rather than xs:integer() to get it from a string. But failing that, you can output it as an integer by converting it to an integer using xs:integer(), or if you want more control, by using the format-number function.

RE: How to adjust number format? - Added by Anonymous almost 14 years ago

Legacy ID: #8537563 Legacy Poster: Joel Shellman (ikestrel)

Is there some way to set the default format for how it outputs numbers? Scattering data type checks and format-number's all over the whole transform seems pretty silly to change the formatting of number output. Is there some way to set the default format for number output for the whole transform?

RE: How to adjust number format? - Added by Anonymous almost 14 years ago

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

If you mean changing the way that casting from xs:double to string works, no: this operation is context-free, and is fully defined by the language specifications. If you want a different operation from the default double-to-string conversion, I'd suggest you use a user-defined function for it.

    (1-3/3)

    Please register to reply