[xslt] Number conversions



Hiya,

This probably isn't an issue for libxslt, but I am asking here mostly for
advice as to directions to go...

Within the stylesheets I'm working on I would like to take a number in the
source XML and convert it to a different base. The primary reason for this
is that although I'm specifying hex numbers in my base XML (it's simpler
to remember 400C0 than 262336), I would like to have both formats in the
output document.

As far as I can tell this isn't possible with the functions I have seen;
format-number seems biased toward decimal and is not therefore useful to me
(unless I have missed something).

Ideally I would be looking for a function that took a similar form to :
  convert-number(string str,number frombase,number tobase)
where :
  str is a string which may be white-space padded.
  frombase is the initial base from which the number is to be converted.
  tobase is the base to which the number should be converted.
  Invalid conversions will return the string 'NOTANUMBER' (or whatever
  equivilent is necessary).

Conversion is performed using the normal methods - A-Z (or a-z) are used to
indicate values >10 in a number. Whitespace before a number is skipped.
Conversion terminates at the first whitespace character. Any character
encountered which is not part of the acceptable base causes the conversion
to be invalid.

If no such implementation is currently available, I may implement it as a
private function in libxslt, but I would prefer to avoid that if some other
mechanism gives me the means to do this.

Any suggestions on where to go from here ? Should I talk to the exslt people
about adding it in their hierarchy ?

-- 
Gerph {djf0-.3w6e2w2.226,6q6w2q2,2.3,2m4}
URL: http://www.movspclr.co.uk/
... Eyes to the heavens, screaming at the sky;
    Trying to send you messages, but choking on goodbye.




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]