On Jan 16, 2011, at 10:06 AM, Ivan Ponomarev wrote:
> Hello again,
>
> another question:
>
> 2. Is there some direct way to set comma as decimal separator for number
> input fields? Comma is the the standard for decimal separator in Russia
> and for end users of the form, in XML file there should still be dot.
For this and for any other kind of localization, one simple approach
is this: instead of binding the user-interface widget to the element
in the main document instance, calculate its (string) value by some
XPath expression - and when the widget is changed by the user,
perform the opposite calculation.
It may be simpler if you create an auxiliary document to hold
an element with the localized value. Then the value of the
localized element may be calculated from the 'standard' value
by an expression like
translate(instance('main')/std-num, '.', ',')
and conversely, the value of the standard element can be
calculated from the localized element by
translate(instance('localized')/localized-num, ',', '.')
Of course, you'll have to enforce the constraints on the
lexical form of the number yourself, and you'll also have to
do your own constraints for things like minimum and maximum
value. But it's not really too hard.
The W3C i18n working group pushed hard for XSD datatypes
to have formats that are standardized and very simple; one
reason was that they hoped to ensure that almost everyone
would have to write a localization layer into their software to
show the data to the user in a form the user would find natural.
(They were disappointed that the date format took the form
specified by ISO 8601; they would have preferred a simple
integer indicating the number of days since some epoch.)
It might be a helpful enhancement of XForms to build some
localization layer into the spec. But in the meantime, it should
not be too hard to do it yourself in the form.
I hope this helps.
Michael Sperberg-McQueen
--
****************************************************************
* C. M. Sperberg-McQueen, Black Mesa Technologies LLC
* http://www.blackmesatech.com
* http://cmsmcq.com/mib
* http://balisage.net
****************************************************************
|