XForms/Load from XML Schema

Motivation
Many times the data types of your data are defined in an external XML Schema file. To use this information, rather than having to explicitly bind the instance to a data type, you can just load the XML Schema file to initialize instance data in the model. The data types will be inferred from the XML Schema file.

To do this you must add a  attribute to the model where the value of the argument is the XML Schema source file. Note that the argument is  NOT. is used to read in the instance data.

Screen Image
Here is a screen image of a sample program. Note that input form for the date and boolean data types are automatically inferred from the XML Schema and different controls are placed in the user interface.



Note that in this example, the order of the controls is also changed.

Link to XForms Application
Load Datatypes from XML Schema

XML Schema diagram
The following is an XML Schema diagram with data types visible. Note that the data type is displayed directly under the data element. This diagram also shows optional data elements using a dashed line and the cardinality of the data elements.



Testing
One of the ways to test if the data types are loaded correctly from the XML Schema file is to attempt to enter an invalid value of a specific data type. XForms should automatically check to see if the input field meets the data requirements specified in the XML Schema file.

For example in the positive integer fields you can attempt to enter a "-1". After you do this and enter a "tab" the background of the form should display in pink as a warning. This is how the screen should look:



The way you display invalid controls is controled by the following line in the CSS file: *:invalid { background-color: red; }

This is known as a pseudo element. Although there are no data elements called "invalid", XForms just adds this property to each input control and the style sheet then adds whatever properties you give it in the style sheet.

Discussion
This program also uses a CSS to display the data elements.

Known bugs
Note that under the bindings do not work if there is no sample instance data.

In addition to this section, it may not be supported in other Xform platforms. Tested in XSLTForms, it does not work, with latest version as of 06/09/10 Used FormFaces, it worked, but could not render the css correctly.

There are also cross-browser compatibility issues as well.