This information is in part taken from the O'Reilly book XForms Essentials. Used with permission.

Model Item Properties

Model item property is the somewhat unwieldy name XForms gives to XPath nodes that have additional XForms properties. XForms defines a number of such properties that, through the flexibility of XPath, can be applied readily to the instance data.

List of Properties

XForms 1.0 defines the following useful properties:

required
This property, when set to true() or 1, signals that the attached instance data must not be blank, and will prevent submission until that condition is met.
relevant
This property controls whether the attached instance data is relevant or not. Non-relevant items are usually not rendered (although this can be fine-tuned with stylesheets) and even not submitted.
readonly
This property controls whether the attached instance data is read-only, in which case it can't be user-modified.
calculate
This property bears a full XPath expression, which can include mathematical operators and function calls, which is used to automatically provide a value to the attached instance data nodes. Multiple calculations can interact, and like a spreadsheet, they will recalculate in the proper order for dependencies to work out.
constraint
This property bears a full XPath expression which must evaluate to true() in order for the attached instance data to be considered valid. Therefore, all constraints must be met before submission can succeed.
type
This property associates a datatype (taken from XML Schema) with the attached instance data nodes. Datatypes can be useful in refining the view into data, for example using a calendar control to enter a date.
p3ptype
This property associates a datatype (taken from P3P) with the attached instance data nodes. P3P datatypes are useful for privacy monitoring, namely smart user agents that keep track of what information they give out. It can also serve as a flag for the client to pre-fill certain allowed kinds of information.

Keep in mind that in XPath expressions, no default namespace applies, and thus prefixes must be used liberally.

XPath Expressions

All of these properties, other than type and p3ptype accept full XPath expressions, which can contain more than the "location path" expressions earlier lessons have used. Some examples:

../price * ../quantity
string-length('hello world!')
total * instance('taxtable')/taxrate

Some commonly-used XPath features are backing up to a parent node (..), addition (+), subtraction (-), multiplication (*), division (div), string length counting (string-length()), checking one string for another (contains()), calculating a sum of several nodes (sum()), and referring to data in an <instance> with a given ID (instance()).

By way of review

Answer the multiple choice questions below.

View Source : Validate

In the next lesson, you will learn more about XForm's "form controls".