Skip to content
Hub Nexus

No author yetClaim it

Version 1Updated 1 min read

Support

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.

Get each new page of

XForms

Following means one email when a page is added, nothing when a page changes.

Following means one email when a page is added, nothing when a page changes.

Comments

Spinner Logo

Next in XForms

CC BY-SA 4.0
Your input instance is like the following: id="link-items" xmlns=""> 1 One 2 Two 3 Three ## Discussion With XForms it is not possible to create dynamic links inside a repeat using a combination of **output**, **value** and **concat**. This would also impact the ability to notify the user that is nav
CC BY-SA 4.0
XForms, Switch and Case
CC BY-SA 4.0
ref="/var/first" > Should I show the second question? /> select="yes"> Yes Please! 1 No Thank You 0 /> ref="/var/second"> Second value: ## Using Multiple Predicates in Binds Sometimes you have a sequence of many items and the display of one item depends on the values of other items. Predicates are a
CC BY-SA 4.0
Then we add a predicate to turn on or off that entire group. In this case if the code is "yes" the input field will be displayed. If it is not the field will be hidden. ref=".[code='yes']"> ref="field"> Conditional Display: ## Complete Example xmlns=" xmlns:xf=" Binds in Repeats type="text/css"> @na
CC BY-SA 4.0
When you are done setting the months the control is set back to the hidden mode. ![XForms Control Visible]( XForms Control Visible (Image: The original uploader was Dmccreary at English Wikibooks ., CC BY-SA 3.0) ## Sample Code xmlns=" xmlns:xf=" xmlns:ev=" Show/Hide Control type="text/css"> @namesp
CC BY-SA 4.0
John Fred Sue Here is an example of this rule: id="triggerDisplay" nodeset="display-delete" relevant="count(/data/person) > 1"/> The above uses the XPath count() function with the greater than operator. But since it must be escaped you must use the ">" instead of ">". Or alternatively the delete but