format-integer with non-decimal output

After today's discussion I was thinking again about the compatibility issues with the picture syntax.

It's legal but extremely unlikely that someone might be using a picture string such as 16^0000 with XPath 3.1; the risk of existing code breaking is tiny. A more real problem, however, is that someone might intentionally use the 4.0 syntax 16^0000, and then run the code under an XPath 3.1 processor, which would produce somewhat bizarre output rather than raising an error.

There's a solution which happens to solve two other problems at the same time: if the radix is anything other than 10, then the character used for the mandatory-digit-sign must be "x" or "X". So a hex format with 8 digits is written 16^xxxx_xxxx, for example. 

The first other problem this solves is that it avoids any suggestion that it might be possible to use non-ASCII digits (such as Indic Arabic digits) when formatting numbers to a base other than 10.

The second other problem is that it gives a convenient way to request lower-case or upper-case hex digits in the output.

Michael Kay
Saxonica

Received on Tuesday, 25 April 2023 19:34:38 UTC