问题
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=". > 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!
回答1:
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).
来源:https://stackoverflow.com/questions/8667849/making-xforms-enforce-the-constraint-and-type-model-item-properties-only-when-fi