Hi All,
I'm using OPS 3.0.1 and I need to use italian format for numbers in xforms ('.' as grouping separator and ',' for decimal separator). For example, if I have in an xml-document an unformatted value 123456.78, the user should see 123.456,78. Of course, use of this number format is needed either in formatting or in parsing user inputs. Thanks -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/wws |
Vincenzo,
You can use <xforms:output ref="/path/to/element" xxforms:format="format-number(.,'000.000.000.000,00')"/> This should work, although I haven't tested it :-) Ryan Puddephatt Software Engineer Teleflex Group - IT UK 1 Michaelson Square Livingston West Lothian Scotland EH54 7DP e> [hidden email] t> +44(0)1506 407 110 f> +44(0)1506 407 108 >-----Original Message----- >From: Vincenzo Garofalo [mailto:[hidden email]] >Sent: 05 September 2006 17:18 >To: [hidden email] >Subject: [ops-users] xforms number format > >Hi All, > >I'm using OPS 3.0.1 and I need to use italian format for >numbers in xforms ('.' as grouping separator and ',' for >decimal separator). For example, if I have in an xml-document >an unformatted value 123456.78, the user should see 123.456,78. >Of course, use of this number format is needed either in >formatting or in parsing user inputs. > >Thanks > > > > > -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/wws |
Thank you Ryan, but the xforms engine interprets the '.' char as
default decimal separator. With your hint, I obtain this error:
format-number picture: There must only be one decimal separator in a sub-picture This is beacause '.' and ',' characters are standard in pattern definition. The same problem has a good solution in XSL, defining a new default decimal format: <xsl:decimal-format decimal-separator = "," grouping-separator = "." infinity = "infinito" minus-sign = "-" NaN = "NaN" percent = "%" per-mille = "‰" zero-digit = "0" digit = "#" pattern-separator = ";" /> In this case, it's possible to define a new "number picture", changing decimal separator and grouping separator. It's possible to set the "number picture" for xforms engine also? thanks Ryan Puddephatt ha scritto: Vincenzo, You can use <xforms:output ref="/path/to/element" xxforms:format="format-number(.,'000.000.000.000,00')"/> This should work, although I haven't tested it :-) Ryan Puddephatt Software Engineer Teleflex Group - IT UK 1 Michaelson Square Livingston West Lothian Scotland EH54 7DP e> [hidden email] t> +44(0)1506 407 110 f> +44(0)1506 407 108-----Original Message----- From: Vincenzo Garofalo [[hidden email]] Sent: 05 September 2006 17:18 To: [hidden email] Subject: [ops-users] xforms number format Hi All, I'm using OPS 3.0.1 and I need to use italian format for numbers in xforms ('.' as grouping separator and ',' for decimal separator). For example, if I have in an xml-document an unformatted value 123456.78, the user should see 123.456,78. Of course, use of this number format is needed either in formatting or in parsing user inputs. Thanks -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/wws |
Vincenzo,
There may be a way to do this in Orbeon, but I'm
not exactly sure, this may be one for Erik or Alex
Ryan
Ryan
Puddephatt
-- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/wws |
Administrator
|
In reply to this post by Vincenzo Garofalo
Vincenzo,
I start to understand. We do not have the equivalent of xsl:decimal-format. But you could still use format-number() and then use the XPath translate() function around it, e.g.: xxforms:format="translate(format-number(...), '.,', ',.')" Note that you can xforms:format on xforms:output, or also change the global definitions in properties.xml. Would something like this work for you? -Erik Vincenzo Garofalo wrote: > Thank you Ryan, but the xforms engine interprets the '.' char as default > decimal separator. With your hint, I obtain this error: > > format-number picture: There must only be one decimal separator in a > sub-picture > > This is beacause '.' and ',' characters are standard in pattern definition. > > The same problem has a good solution in XSL, defining a new default > decimal format: > > <xsl:decimal-format > decimal-separator = "," > grouping-separator = "." > infinity = "infinito" > minus-sign = "-" > NaN = "NaN" > percent = "%" > per-mille = "‰" > zero-digit = "0" > digit = "#" > pattern-separator = ";" /> > > In this case, it's possible to define a new "number picture", changing > decimal separator and grouping separator. > It's possible to set the "number picture" for xforms engine also? > > thanks > > > Ryan Puddephatt ha scritto: >> Vincenzo, >> >> You can use <xforms:output ref="/path/to/element" >> xxforms:format="format-number(.,'000.000.000.000,00')"/> >> >> This should work, although I haven't tested it :-) >> >> Ryan Puddephatt >> Software Engineer >> >> Teleflex Group - IT UK >> 1 Michaelson Square >> Livingston >> West Lothian >> Scotland >> EH54 7DP >> >> e> [hidden email] >> t> +44(0)1506 407 110 >> f> +44(0)1506 407 108 >> >> >> >> >>> -----Original Message----- >>> From: Vincenzo Garofalo [mailto:[hidden email]] >>> Sent: 05 September 2006 17:18 >>> To: [hidden email] >>> Subject: [ops-users] xforms number format >>> >>> Hi All, >>> >>> I'm using OPS 3.0.1 and I need to use italian format for >>> numbers in xforms ('.' as grouping separator and ',' for >>> decimal separator). For example, if I have in an xml-document >>> an unformatted value 123456.78, the user should see 123.456,78. >>> Of course, use of this number format is needed either in >>> formatting or in parsing user inputs. >>> >>> Thanks >>> >>> >>> >>> >>> >>> >> >> >> >> ------------------------------------------------------------------------ >> >> >> -- >> You receive this message as a subscriber of the [hidden email] mailing list. >> To unsubscribe: mailto:[hidden email] >> For general help: mailto:[hidden email]?subject=help >> ObjectWeb mailing lists service home page: http://www.objectweb.org/wws >> > > > ------------------------------------------------------------------------ > > > -- > You receive this message as a subscriber of the [hidden email] mailing list. > To unsubscribe: mailto:[hidden email] > For general help: mailto:[hidden email]?subject=help > ObjectWeb mailing lists service home page: http://www.objectweb.org/wws -- Orbeon - XForms Everywhere: http://www.orbeon.com/blog/ -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/wws |
Erik,
let me explain with an example. In this page, there are two numeric input fields (a and b) and one output field (sum, defined as a + b). The input fields are defined as xs:decimal, so if I type numbers in correct format I obtain the sum. Of course, validation fails if I type a number with the ',' character as decimal separator and a '!' character appears near the field. Therefore using format and translate functions does not resolve the problem because number in this format needs a correct validation, not only a correct presentation.Also, if I treat a and b as string with a particular format, sum will not work. I hope this will help you understand my problem. Consider that this is a general problem because a very large number of countries (probably most of the countries where language is not english) use ',' as decimal separator and '.' or whitespace as grouping separator. thank you - Vincenzo <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http:/www.example.org/ui" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xforms="http://www.w3.org/2002/xforms"> <head> <title>Number format test</title> <xforms:model> <xforms:instance> <values xmlns=""> <a ui:valid="" ui:show-valid="" ui:show-invalid="">0</a> <b ui:valid="" ui:show-valid="" ui:show-invalid="">0</b> <sum /> </values> </xforms:instance> <xforms:bind nodeset="/values/a" type="xs:decimal" /> <xforms:bind nodeset="/values/b" type="xs:decimal" /> <xforms:bind nodeset="/values/sum" calculate="/values/a + /values/b" /> </xforms:model> </head> <body> <table> <tr> <td>First number</td> <td><xforms:input ref="/values/a" incremental="true"/></td> </tr> <tr> <td>Second number</td> <td><xforms:input ref="/values/b" incremental="true"/></td> </tr> <tr> <td>The sum is</td> <td><xforms:output ref="/values/sum" /></td> </tr> </table> </body> </html> Erik Bruchez ha scritto: Vincenzo, -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/wws |
Administrator
|
Vincenzo,
> let me explain with an example. In this page, there are two numeric > input fields (a and b) and one output field (sum, defined as a + > b). The input fields are defined as xs:decimal, so if I type numbers > in correct format I obtain the sum. Of course, validation fails if I > type a number with the ',' character as decimal separator and a '!' > character appears near the field. Therefore using format and > translate functions does not resolve the problem because number in > this format needs a correct validation, not only a correct > presentation.Also, if I treat a and b as string with a particular > format, sum will not work. > > I hope this will help you understand my problem. Consider that this > is a general problem because a very large number of countries > (probably most of the countries where language is not english) use > ',' as decimal separator and '.' or whitespace as grouping > separator. I understand the problem even better now. What we need, ideally, is localized input, in particular for the following types: o xs:date o xs:dateTime o xs:time o xs:decimal o etc. Obviously, the perfect solution at the moment does not exist in OPS. This solution would allow you to just add an attribute or property somewhere to tell OPS how you want to format the input, and the XForms engine would take care automatically to convert it to the standard XML Schema type in the instance. A possible stopgap solution could be to simply be able to provide an generic way of specifying an XPath expression to convert from a user-facing value to an instance value. E.g. you could write: <xforms:input xxforms:translate="translate(replace(., '.', ''), ',', '.')" xxforms:format="format-number(., ...)" ...> (Can we write a simpler XPath expression?) This translation would occur as the XForms engine writes the data to the instance. So if you enter "1.234,00" the value stored into the instance, and then validated, would be "1234.00". Granted, this would be fairly heavy and not ideal at all, but it would do the job. We are of course open to suggestions: what in your opinion is the best way to implement this feature? -Erik -- Orbeon - XForms Everywhere: http://www.orbeon.com/blog/ -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/wws |
Thank you Erik for your answer,
of course, we think that the best way to implement this feature is to define a global property for the XForms engine. In this way, it's possible to change all number presentation without modifying every page. We have tried to modify source to add the fetaure in this way: Added a constant in org.orbeon.oxf.xforms.XFormsConstants public static final String XFORMS_DEFAULT_DECIMAL_FORMAT_PROPERTY = "oxf.xforms.format.decimal"; Added this property in property.xml file: <property as="xs:string" name="oxf.xforms.format.decimal" value="if (. castable as xs:decimal) then translate(format-number(xs:decimal(.),'#,##0.00'),'.,',',.') else ."/> Added xs:decimal type handling in org.orbeon.oxf.xforms.control.XFormsValueControl, method evaluateDisplayValueUseFormat() With this modification, we have obtained the correct format on numbers using xforms:output. For the reverse function (user input number parsing), we encountered some difficulties due to the complexity of xforms implementation and event handling, but we think that, for who knows code, it's not to hard to implement this feature. Best Regards, vincenzo Erik Bruchez ha scritto: Vincenzo, -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/wws v.garofalo.vcf (321 bytes) Download Attachment |
Administrator
|
Vincenzo,
> of course, we think that the best way to implement this feature is to > define a global property for the XForms engine. In this way, it's > possible to change all number presentation without modifying every page. > > We have tried to modify source to add the fetaure in this way: > > Added a constant in *org.orbeon.oxf.xforms.XFormsConstants > > * public static final String XFORMS_DEFAULT_DECIMAL_FORMAT_PROPERTY = > "oxf.xforms.format.decimal"; > > Added this property in property.xml file: > > <property as="xs:string" name="oxf.xforms.format.decimal" value="if > (. castable as xs:decimal) then > translate(format-number(xs:decimal(.),'#,##0.00'),'.,',',.') else ."/> > > Added xs:decimal type handling in > *org.orbeon.oxf.xforms.control.XFormsValueControl*, method > *evaluateDisplayValueUseFormat*() > > With this modification, we have obtained the correct format on > numbers using xforms:output. Thanks, we have integrated something like this in the code now, and hooked up formatting for types including xs:decimal, xs:integer, xs:float and xs:double. The documentation is available here: http://www.orbeon.com/ops/doc/reference-xforms-ng#xforms-default-formatting > For the reverse function (user input number parsing), we encountered > some difficulties due to the complexity of xforms implementation and > event handling, but we think that, for who knows code, it's not to > hard to implement this feature. This part will have to wait a little bit more. -Erik -- Orbeon - XForms Everywhere: http://www.orbeon.com/blog/ -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/wws |
vincenzo Erik Bruchez ha scritto: Vincenzo, -- You receive this message as a subscriber of the [hidden email] mailing list. To unsubscribe: mailto:[hidden email] For general help: mailto:[hidden email]?subject=help ObjectWeb mailing lists service home page: http://www.objectweb.org/wws |
Free forum by Nabble | Edit this page |