使 XForms 仅在填充字段时强制执行约束和类型模型项属性

发布于 2024-12-23 05:40:15 字数 431 浏览 3 评论 0原文

我有一个带有输入字段的简单 XForm,其中我已使用 required="false()" 属性指定该字段为可选字段。但是,我想向字段添加类型和约束属性以强制执行整数类型,并且整数必须大于 10,但前提是在字段中输入数据;毕竟,该字段是可选的。例如:

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

我本以为 required="false()" 会胜过类型和约束属性,但我似乎错了;看来,包括类型和约束会强制填写该字段。根据 XForms 1.1 规范,这是正确的行为吗?无论如何,有没有办法在 XForms 中做我想做的事情?

谢谢!

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

〆一缕阳光ご 2024-12-30 05:40:15

尝试使用 type="xforms:integer" 而不是 type="xs:integer"。 Orbeon 自 2007 年起就以这种方式支持 XForms 1.1 类型(请参阅Orbeon Forms 3.6 的发行说明,“值得注意的更改”的第四点和问题#307162)。

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).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文