マガジン XForms · 137 ページ中 49 ページ目
Motivation
You want the view portion of your form to add formatting information to numbers. For example, you want your US currency to be stored in the model as 12345.6789 but the view to display at $12,345.68. Note that the dollar sign is used as a prefix, commas are added and the decimal is rounded to two digits.
Ideally, we would like to use a simple CSS function to indicate that all currency should be formatted using the standard number picture formats such as "$#,###.##".
Method
If all browsers supported the XPath 2.0 format-number() function, this would be trivial. Till then the developer will need to resort to workaround such as using JavaScript and the XML Binding language (XBL).
Sample Code
nodeset="instance('invoice')/Total" calculate="round((instance('invoice')/Tax + instance('invoice')/SubTotal) * 100) div 100"/>
References
Mozilla page on XForms custom controls
The following discussions on the XForms mailing lists might be helpful.
Dan McCreary's Post to the Mozilla XForms discussion group
John Boyer's Comments on Number Formatting in XForms
acknowledgement of the currency format needs in the 2001 working draft of XForms
Where this page came from
This page was imported from Wikibooks. From “XForms” on Wikibooks, by its contributors, under CC BY-SA 4.0. Changed here: set as a page; navigation and edit links left out; each image under its own licence, credited in its caption.
Nobody has written it yet — it is the source material at a new address, which is why search engines are asked to skip it and why no one earns from it. It is up for grabs: take it on, and it is yours to rewrite and to earn from.
このページを含むマガジンXForms
ライセンス: CC BY-SA 4.0 · 出典 en.wikibooks.org
1
0
0
0

コメント






