6.1 Model Item Property
Definitions

Fixed properties are static values that the XForms Processor
evaluates only once. Such properties consist of literals, and are
not subject to XPath evaluation.

Computed
expressions are XPath expressions that provide a value to the
XForms Processor. Such values are recalculated at certain times as
specified by the XForms Processing Model (see 4 Processing Model). These
expressions encode dynamic properties, often constraints, such as
the dependency among various data items. Computed expressions are
not restricted to examining the value of the instance data node to
which they apply. XPath expressions provide the means to traverse
the instance data; more complex computations may be encoded as
call-outs to external scripts.

Inheritance rules:

Some model item properties define inheritance rules, in which
case the XForms processor needs to keep track of two separate
values: 1) the local value, which is applied from an
attribute of element bind, and 2) the inherited
value, which is determined by combining the evaluated local
value with the evaluated values from ancestor nodes in the instance
data.

Note:

The sample recalculation algorithm defined in D Recalculation Sequence Algorithm is
defined to operate only on the local values of a model item
property. It assumes that an implementation propagates the combined
values to a node's descendants.

Assigning local values:

Local values are assigned by processing all bind elements in an
XForms Model in document order. It is an error to attempt to set a
model item property twice on the same node. The details of this
process are given at 4.2.2 The
xforms-model-initialize Event.

The following sections list the model item properties available
as part of all model items. For each, the
following information is provided:

Inheritance Rules: If any ancestor node evaluates to
true, this value is treated as true.
Otherwise, the local value is used.

Note:

This is the equivalent of taking the logical OR of the evaluated
readonly property on the local and every ancestor
node.

When evaluating to true, this model item property
indicates that the XForms Processor should not allow any changes to
the bound instance data node.

In addition to restricting value changes, the
readonly model item property provides a hint to the
XForms user interface. Form controls bound to instance data with
the readonly model item property should indicate that
entering or changing the value is not allowed. This specification
does not define any effect on visibility, focus, or navigation
order.

6.1.3 The required Property

Description: describes whether a value is required before the
instance data is submitted.

Computed Expression: Yes.

Legal Values: Any expression that is convertible to XPath
boolean with boolean().

Default Value: false().

Inheritance Rules: does not inherit.

A form may require certain values, and this requirement
may be dynamic. When evaluating to true, this model
item property indicates that a non-empty instance data node is
required before a submission of instance data can occur. Non-empty
is defined as:

If the bound instance data node is an element, the element must
not have the xsi:nil attribute set to
true.

The value of the bound instance data node must be convertible to
an XPath string with a length greater than zero.

Except as noted below, the required model item
property does not provide a hint to the XForms user interface
regarding visibility, focus, or navigation order. XForms authors
are strongly encouraged to make sure that form controls that accept
required data are visible. An XForms Processor may
provide an indication that a form control is required, and may
provide immediate feedback, including limiting navigation. Chapter
4 Processing Model contains
details on how the XForms Processor enforces required values.

Here, we have associated a required property with
element my:last-name to indicate that a value must be
supplied.

Note:

XML Schema has a similarly named concept with
use="required|optional|prohibited". This
is different than the XForms model item property, in two ways: 1)
use applies only to attributes, while XForms
required applies to any node. 2) use is
concerned with whether the entire attribute must be specified
(without regard to value), while required determines
whether a value is required of the node before submission.

6.1.4 The relevant Property

Description: indicates whether the model item is currently
relevant. Instance data nodes with this property
evaluating to false are not serialized for
submission.

Computed Expression: Yes.

Legal Values: Any expression that is convertible to XPath
boolean with boolean().

Default Value: true().

Inheritance Rules: If any ancestor node evaluates to XPath
false, this value is treated as false.
Otherwise, the local value is used.

Note:

This is the equivalent of taking the logical AND of the
evaluated relevant property on the local and every
ancestor node.

Many forms have data entry sections that depend on other
conditions. For example, a form might ask whether the respondent
owns a car. It is only appropriate to ask for further information
about their car if they have indicated that they own one.

The relevant model item property provides hints to
the XForms user interface regarding visibility, focus, and
navigation order. In general, when true, associated
form controls should be made visible. When false,
associated form controls should be made unavailable, removed from
the navigation order, and not allowed focus.

Here, we have associated a relevant property with
element my:discount to indicate a discount is relevant
when the order amount is greater than 1000.

The following table shows the user interface interaction between
required and relevant.

required="true()"

required="false()"

relevant="true()"

The form control (and any children)
must be visible or available to the user. The XForms user interface
may indicate that a value is required.

The form control (and any children)
must be visible or available to the user. The XForms user interface
may indicate that a value is optional.

relevant="false()"

The form control (and any children)
must be hidden or unavailable to the user. Entering a value or
obtaining focus should not be allowed. The XForms user interface
may indicate that should the form control become relevant, a value
would be required.

The form control (and any children)
must be hidden or unavailable to the user. Entering a value or
obtaining focus should not be allowed.

6.1.5 The calculate Property

Description: supplies an expression used to calculate the value
of the associated instance data node.

Computed Expression: Yes.

Legal Values: Any XPath expression.

Default Value: none.

Inheritance Rules: does not inherit.

An XForms Model may include model items that are computed from
other values. For example, the sum over line items for quantity
times unit price, or the amount of tax to be paid on an order. Such
computed value can be expressed as a computed expression using the
values of other model items. Chapter 4
Processing Model contains details of when and how the
calculation is performed.

Here, we have associated a relevant property with
element my:discount to indicate a discount of 10% is
relevant when the order amount is greater than 1000.

6.1.6 The constraint Property

Description: specifies a predicate that needs to be satisfied
for the associated instance data node to be considered valid.

Computed Expression: Yes.

Legal Values: Any expression that is convertible to XPath
boolean with boolean().

Default Value: true().

Inheritance Rules: does not inherit.

When evaluating to XPath false, the associated
model item is not valid; the converse is not necessarily true.
Chapter 4 Processing Model
contains details of when and how the constraint is calculated as
well as when validation is performed.

Here, we have associated a constraint property with
element my:to to indicate that its value must be
greater than that of element my:from.

6.1.7 The maxOccurs Property

Description: for repeating structures, indicates the maximum
number of allowed element nodes.

Computed Expression: Yes.

Legal Values: Any XPath expression. The result is evaluated as
an XPath Number.

Default Value: INF.

Inheritance Rules: does not inherit.

For model item elements that are repeated, this optional model
item property specifies a maximum number of allowed element nodes.
Negative results, Infinity, or NaN have the effect of
not setting any limit.

Here, the example associates both minOccurs and
maxOccurs properties with element my:item
to indicate that there must be a minimum of one and a maximum four
elements my:item for the instance to be considered
valid.

Note:

XForms model item properties minOccurs and
maxOccurs are designed to be isomorphic to the
corresponding XML Schema facets minOccurs and
maxOccurs. The properties minOccurs and
maxOccurs are intended to specify the cardinality of a
set and therefore should not be applied to individual members of
the nodeset. Thus, <bind nodeset="/bookmarks/bookmark"
minOccurs="8"/> is meaningful, but it is undefined to
apply this property to an individual member of the nodeset e.g.,
<bind nodeset="/bookmarks/bookmark[1]"
minOccurs="8"/>

6.1.8 The minOccurs Property

Description: for repeating structures, indicates the minimum
number of allowed element nodes.

Computed Expression: Yes.

Legal Values: Any XPath expression. The result is evaluated as
an XPath Number.

Default Value: 0.

Inheritance Rules: does not inherit.

For model item elements that are repeated, this optional model
item property specifies a minimum number of allowed element nodes.
Negative results, Infinity, or NaN have the effect of
not setting any limit.

This model item property holds a description of the kind of data
collected by the associated instance data node, based on the P3P
datatype system [P3P 1.0].
This information may be used to enhance the form-fill experience,
for example by supplying previously-known data from a server.

6.2 Schema
Constraints

Chapter 5 Datatypes described
how XForms uses the XML Schema datatype system to constrain the value
space of data values collected by an XForms Model. Such
datatype constraints can be provided via an XML Schema.
Alternatively, this section lists various mechanisms for attaching
type constraints to instance data. Attributes
xsi:schemaLocation and
xsi:noNamespaceSchemaLocation are ignored for purposes
for locating a Schema. XForms Basic processors have restricted
Schema processing requirements as defined in 12.1.2 XForms
Basic.

6.2.1
Atomic Datatype

The XForms Processing Model applies XML Schema facets as part of
the validation process. At the simplest level, it is necessary to
associate a set of facets (through an XML Schema datatype) with a
model item. This has the effect of restricting the allowable values
of the associated instance data node to valid representations of
the lexical space of the datatype.

The set of facets may be associated with a model item in one of
the following ways (only the first that applies is used, and if
multiple type constraints apply to the same node, the first
definition in document order is used).

An XML Schema associated with the instance data.

An XML Schema xsi:type attribute in the instance
data.

An XForms type constraint associated with the
instance data node using XForms binding.

If no type constraint is provided, the instance data node
defaults to type="xsd:string" (default to string
rule).

The following declares a datatype based on
xsd:string with an additional constraining facet.