XForms/Facet Validation

Motivation
XML Schemas contain a large amount of data element constraint information other than just the data type. These restrictions on a specific data type are called "facets". Different data types have different types of facets. For example strings may have minimum and maximum length values and integers may have minimum and maximum numeric values.

This program demonstrates how XForms can validate a data set based on the facets within and XML Schema.

Warnings
Note: This program does not run under the FireFox 0.6 extension.

The X-Smiles browser was used to demonstrate this program.

Screen Image
This screen image was taken from the X-Smiles implementation of XForms.



Note that the second field is not at least three characters long so the field is invalid and the background it set to pink according to the CSS style for invalid fields.

XML Schema (schema.xsd)
Here is a simple XML Schema with four strings. The first one is only allowed to be two characters long. The second must have a minimum length of three characters. The third string must not be over five characters long and the fourth one must be between five and seven characters long to be valid.

Sample Program
The following program loads both the XML Schema and initial instance data from two external files (schema.xsd and instance.xml). The initial data in this example is valid but you can change the data to test the validation.

The two lines that load the XML Schema and instance data are:

Also note that the input fields have the incremental attribute set to true. This allows character-by-character validation. The form is revalidated with each key stroke.