Search code examples
orbeonxforms

Making XForms enforce the constraint and type model item properties only when field is populated


I have a simple XForm with an input field where I have specified the field to be optional with the required="false()" property. However, I would like add a type and constraint property to the field to enforce an integer type and that the integer must be greater than 10, but only if data is entered in the field; after all, the field is optional. For example:

<xf:bind nodeset="testGreaterThanTen"
         required="false()"
         type="xs:integer"
         constraint=". &gt; 10"/>

I would have thought the required="false()" would trump the type and constraint properties, but I appear to be wrong; it appears that including the type and constraint forces the field to be filled out. Is this the proper behavior per the XForms 1.1 specification? Is there anyway to do what I want in XForms?

Thanks!


Solution

  • Try type="xforms:integer" instead of type="xs:integer". Orbeon supports the XForms 1.1 types this way since 2007 (see the Release Notes for Orbeon Forms 3.6, fourth point of "Noteworthy Changes" and issue #307162).