XForms/Form Generators

From Wikibooks, open books for an open world
Jump to navigation Jump to search

Motivation[edit | edit source]

You want to generate a user interface form directly from a model.

Method[edit | edit source]

Because XForms is a declarative XML file it can be generated by transforming a model of your data directly into a form. The most common way to store a model of hierarchical data is using an XML Schema. A server-side program will scan the XML Schema document and for each element found it will create the appropriate XForms elements.

Generated forms have the advantage over hand-crafted forms in that they can can be generated with the same set of transforms. If you change your form standards all the forms can be quickly be regenerated. Many of these advantage can be gained by pushing the formatting and layout functionality of a form into CSS style sheets. But there are also many aspects of a form that are not governed by a style sheet.

If you using a consistent naming convention in your forms you can also use this naming convention to decide what types of input controls to generate based on the information in the element name. For example simple names and amounts will map to input controls, boolean true/false values will map to inputs formatted as checkboxes, dates will use calendar selectors, text objects will use textarea controls and codes will use select or select1 controls.

Here is a sample of how ISO Data element Representation Terms map to XForms controls:

Representation Term XForms Control
Amount, Name input
Indicator input with type="xs:boolean"
Date input with type="xs:date"
Text Textarea

References[edit | edit source]

Discussion[edit | edit source]

Next Page: NIEM to XForms | Previous Page: IBM DB2
Home: XForms