Type annotations
Basics
Orbeon Forms supports exposing MIP type annotations to XPath 2.0.
This means that if you have a type associated with a node, e.g.:
then the type is not only used for validation, but also determines the typed value of the element node age.
This means that earlier, you had to write the following:
With exposing type annotations, you can simply write:
or:
Enabling type annotations
NOTE: Type annotations are not automatically enabled for backward compatibility reasons. However, they are enabled by default for new forms created with Form Builder.
The following property controls whether instance types annotations are exposed to XPath 2.0 expressions:
If set to
false
(the default), instance types are not made available to XPath expressions.If set to
true
, they are made available.
You can as usual enable this on a per-page basis:
[SINCE Orbeon Forms 4.2]
You can also enable this on a per-instance basis:
Where does this work?
Static type annotations (with xf:bind/@type
and xsi:type
) can be used by all XPath expressions, including xf:bind/@calculate
.
NOTE: Here is the order in which the XForms engine processes type annotations in the model:
during a model rebuild, all
xf:bind
point to their associated instance nodes if anystatic type annotations with
xf:bind/@type
andxsi:type
are available just after a rebuildthis means that type annotations can be used during subsequent model recalculate _and _revalidate
however, annotations done via a schema are not reliably available during recalculate