XForms - Model Item Properties (MIPs)

Standard MIPs


Making an entire instance read-only

You often want to present a form without allowing the user to enter data. An easy solution is to use the readonly MIP in the model. By making for example the root element of an instance read-only, all the controls bound to any node of that instance will appear read-only (because the read-only property is inherited in an instance):

<xf:bind ref="instance()" readonly="true()"/>


Multiple binds on a given node

NOTE: As of 2012-11, this is scheduled to be standardized in XForms 2.

Properties (MIPs) have a default value:
  • required: false
  • valid: true (depends on a series of conditions, including "required")
  • relevant: true
  • readonly: false
The resulting value of a property on a given node when multiple binds touch that node is the result of a boolean combination:
  • required: boolean or
  • valid: boolean and
  • relevant: boolean and
  • readonly: boolean or
Consider the following example:

    <xf:bind ref="instance()//*" required="true()"/>
    <xf:bind ref="instance()/some-node" required="false()"/>

some-node's required property is here set to true, and the order of the two binds doesn't matter.

NOTE: This is the behavior with Orbeon Forms 3.9 onwards. With Orbeon Forms 3.8, the combination was based on bind order.

Extension XPath functions

Custom MIPs

You can place user-defined Model Item Properties (MIPs) on the <xf:bind> element.

Any attribute not in a standard Orbeon namespace is interpreted as a custom MIP:

<xf:bind ref="*" foo:bar="if (starts-with(., 'g')) then 'is-g' else 'is-not-g'"/>

The value of the attribute must be a valid XPath expression. The expression result is converted to a string to set the MIP value.

Custom MIPs have the side effect of placing CSS classes on controls bound to affected nodes. Class names are computed as the concatenation of:

  • MIP attribute prefix
  • "-"
  • MIP attribute local name
  • "-"
  • MIP value

With the example above, the following class names can be set: foo-bar-is-g or foo-bar-is-not-g.

[SINCE 2013-02-14 / Orbeon Forms 4.0.1]

The model supports the xxf:custom-mips attribute, which lists the names of the custom MIPs in use. When this attribute is present, only the attributes with names listed are interpreted as MIPs. Other non-built-in attributes are ignored.

When this attribute is missing, the backward-compatible behavior is enabled and all non-built-in attributes are considered custom MIPs.

It is recommended to use the xxf:custom-mips attribute to specify which attributes are custom MIPs.

<xf:model xxf:custom-mips="foo:bar foo:baz">
    <xf:bind ref="name" foo:bar="normalize-space(.) = ''" foo:baz="42"/>

Dynamic initial values

The xxf:default MIP

In XForms, default or initial values can be set by pre-populating an instance document's elements and attributes with initial data, for example:


For dynamic values, for example coming from request parameters or session values, there is no declarative notation and you must use xforms-submit-donexforms-model-construct-done or xforms-submit-ready, which is sometimes cumbersome:

<xf:setvalue ev:event="xforms-model-construct-done" ref="username" value="xxf:get-request-header('MY_USER')"/>

For convenience, Orbeon Forms support an extension model item property: xxf:default. It works like the standard calculate, except that it is evaluated only once, just before the first evaluation of the calculate expressions if any.

<xf:bind ref="username" xxf:default="xxf:get-request-header('MY_USER')"/>

Forcing recalculation of initial values with the recalculate action

[SINCE: 2010-05-28]

The <xf:recalculate> supports an extension attribute, xxf:defaults, which, when set to true, forces the re-evaluation of initial values before performing the recalculation.

<xf:recalculate xxf:defaults="true"/>

The xxf:defaults attribute is an AVT so can include XPath expressions between curly brackets:

<xf:recalculate xxf:defaults="{instance()/status = 'dirty'}"/>

Deferred rebuild, recalculate and revalidate

[SINCE: 2012-11-28]

XForms provides actions to force a given model's rebuild, recalculate, revalidate. As XForms specifies it, these actions have an immediate effect.

Orbeon Forms provides an extension on those actions to defer the behavior of those actions by just setting the appropriate flags defined in the XForms specification, but not actually running the actions immediately. The actions will run as needed the next time the flags are checked.

<xf:rebuild     xxf:deferred="true"/>
<xf:recalculate xxf:deferred="true"/>
<xf:revalidate  xxf:deferred="true"/>

Static appearance for read-only controls

Sometimes, read-only controls don't appear very nicely in web browsers. For example, a combo box will appear grayed out. It maybe be hard to read, and there is not much point showing a combo box since the user can't interact with it. Furthermore, with some browsers, like IE 6 and earlier, it is not even possible to make disabled controls appear nicer with CSS. In order to make read-only versions of forms look nicer, Orbeon Forms supports a special extention attribute that allows you to produce a "static" appearance for read-only controls. You enable this on your first XForms model:

<xf:model xxf:readonly-appearance="static">

The attribute takes one of two vales: static or dynamic (the default). When using the value static, read-only controls do not produce disabled HTML form controls. This has one major limitation: you can't switch a control back to being read-write once it is displayed as read-only.

You can also set the xxf:readonly-appearance attribute directly on individual XForms controls.

See Form Runner's Preview mode for an example of this feature in action.