Comments? Feedback?

This wiki does not yet support public comments (a limitation of Google Sites), so we encourage you to post your comments either:

On Twitter by responding to @orbeon.

On our community mailing list: subscribe sending an email to ops-users-subscribe@ow2.org (content of subject/body doesn't matter), you'll get a response with the email to use to send your message to the community mailing list.

Recent site activity

XForms - Validation

Rationale

Orbeon Forms validates XForms instances following XForms 1.1 and adds some extensions to facilitate validation.

Validation methods

There are two main methods for validating data in XForms:
  • With an imported XML Schema
  • With xforms:bind
[TODO: document, examples]

Validation order

Orbeon Forms performs validation of a node in the following order:
  • XML Schema validation (lax/strict/none on model instances)
  • bind/@type
  • required-but-empty
  • bind/@constraint
Once a given node is marked as invalid, further validation is not performed. E.g. if a node's type is invalid, then @constraint is not evaluated. [TODO: example]
[TODO: example]

XML Schema validation

[TODO: document]

Validation and submission

[TODO]

Validation and controls

[TODO]

Extensions

Extension events

Orbeon Forms supports extensions events dispatched to an instance when it becomes valid or invalid:

  • xxforms-valid
  • xxforms-invalid.

These events are dispatched just before xforms-revalidate completes, to all instances of the model being revalidated. For a given instance, either xxforms-valid or xxforms-invalid is dispatched for a given revalidation.

These events can be used, for example, to toggle the appearance of icons indicating that a form is valid or invalid:

<xforms:instance id="my-instance">
    ...
</xforms:instance>
<xforms:action ev:event="xxforms-invalid" ev:observer="my-instance">
    <xforms:toggle case="invalid-form-case"/>
</xforms:action>
<xforms:action ev:event="xxforms-valid" ev:observer="my-instance">
    <xforms:toggle case="valid-form-case"/>
</xforms:action>

Extension XPath functions

  • The xxforms:valid() returns the validity of a instance data node or of a subtree of instance data.
  • The xxforms:invalid-binds() function allows you to determine which bind caused node invalidity.

Extension types

Orbeon Forms supports the built-in xxforms:xml extension type. This types checks that the value is well-formed XML:

<xforms:bind ref="my-xml" type="xxforms:xml"/>

Note that this checks the string value of the node, which means that the node must contain escaped XML.

Orbeon Forms supports the built-in xxforms:xpath2 extension type. This types checks that the value is well-formed XPath 2.0. Any variable used by the expression is assumed to be in scope:

<xforms:bind ref="my-xpath" type="xxforms:xpath2"/>

NOTE: In both these cases, Orbeon Forms checks for the required MIP: if it evaluates to false() and the value is the empty string, then the instance data node is considered valid. This is contrary to XForms 1.1 as of August 2008.

Controlling the XML Schema validation mode

When an XML Schema is provided, Orbeon Forms supports controlling whether a particular instance is validated in the following modes:

  • "lax" mode
  • "strict" mode
  • not validated at all ("skip" mode)

Orbeon Forms implements a "lax" validation mode by default, where only elements that have definitions in the imported schemas are validated. Other elements are not considered for validation. This is in line with XML Schema and XSLT 2.0 lax validation modes, and with the default validation mode as specified in XForms 1.1

In addition, the author can specify the validation mode directly on each instance with the extension xxforms:validation attribute, which takes values:

  • lax (the default)
  • strict (the root element has to have a definition in the schema and must be valid)
  • skip (no validation at all for that instance)
<xforms:model schema="my-schema.xsd">
    <xforms:instance id="my-form" xxforms:validation="strict">
        <my-form> ... </my-form>
    </xforms:instance>
    <xforms:instance id="items" xxforms:validation="skip">
        <items> ... </items>
    </xforms:instance>
</xforms:model>

Nodes validated through a schema receive datatype annotations, which means that if an element or attribute is validated against xs:date in a schema, an XForms control bound to that node will display a date picker.

Sign in  |  Recent Site Activity  |  Revision History  |  Terms  |  Report Abuse  |  Print page  |  Powered by Google Sites