XForms 绑定元素错误
我正在更改代码以在 XForms 中使用绑定(这比到处使用节点集更好!),但我收到错误。
我收到的错误消息是:“错误:XForms错误(8):id(data_criterion)没有引用绑定元素...”
从我一直在使用的教程/指南来看,这似乎应该可行,但显然我缺少一些东西! (顺便说一句,我正在按照此处的示例对绑定代码进行建模:http://en.wikibooks。 org/wiki/XForms/Bind)
我最初认为问题是由于我使用 xf:select 控件而不是像示例中的 xf:input 那样的事实,但即使有一次我将代码简化为最简单的简单的代码,我仍然收到错误!
这是我正在使用的模型代码:
<xf:model id="select_data">
<xf:instance id="criteria_data" xmlns="">
<file>
<criteria>
<criterion></criterion>
</criteria>
</file>
</xf:instance>
<bind id="data_criterion" nodeset="instance('criteria_data')/criteria/criterion"/>
</xf:model>
至于 ui 代码,这就是我所拥有的:
<xf:input bind="data_criterion">
<xf:label>Enter criteria:</xf:label>
</xf:input>
我收到的错误消息是:“错误:XForms 错误 (8):id (data_criterion) 不引用绑定元素.. ”
任何人都知道问题出在哪里吗?另外,我应该注意绑定和 xf:select (带有 xf:itemset)控件的任何特殊用法吗? (我最终在我的表单上使用了很多 xf:select 控件..)
提前致谢!
编辑:
我通过这个validator运行代码,我收到了这条消息(指绑定线): “警告:以下元素是否应应用 XForms 命名空间?:bind(第 66 行)”
I am changing my code to use binds in XForms (which is better practice than using nodesets everywhere!) but I am getting errors.
The error message I receive is: "Error: XForms Error (8): id (data_criterion) does not refer to a bind element..."
From tutorials/guides I have been using, it seems as though this should work, but clearly I am missing something! (btw, I was modeling my binding code after the examples here: http://en.wikibooks.org/wiki/XForms/Bind)
I originally thought the problem was due to the fact I was using xf:select controls as opposed to xf:input like the examples, but even once I dumbed down my code to the most simplistic code, I still receive errors!
This is the model code I am using:
<xf:model id="select_data">
<xf:instance id="criteria_data" xmlns="">
<file>
<criteria>
<criterion></criterion>
</criteria>
</file>
</xf:instance>
<bind id="data_criterion" nodeset="instance('criteria_data')/criteria/criterion"/>
</xf:model>
As for the ui code, this is what I have:
<xf:input bind="data_criterion">
<xf:label>Enter criteria:</xf:label>
</xf:input>
The error message I receive is: "Error: XForms Error (8): id (data_criterion) does not refer to a bind element..."
Anyone have any insight to what the problem is? Also, is there any special usage of bindings and xf:select (with xf:itemset) controls that I should be aware of? (I am ultimately using a lot of xf:select controls on my form..)
Thanks in advance!
EDIT:
I ran the code through this validator, and I got this message (refers to the bind line):
"Warning: Should the following element have the XForms namespace applied?: bind (line 66)"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能需要更改一些内容:
nodeset
表达式应该是instance('criteria_data')/criteria/...< /code>,没有
文件
。请记住:instance()
返回根元素,而不是文档节点。 (您通过更新问题来处理这个问题;很好)bind
上缺少xf
。它应该是:
。请参阅下面包含您的代码的完整示例,该示例在 Orbeon Forms 下对我来说效果很好:
A couple of things you might want to change:
nodeset
expression should beinstance('criteria_data')/criteria/...
, withoutfile
. Remember:instance()
returns the root element, not the document node. (This one you took care by updating the question; good)xf
on thebind
. It should be:<xf:bind id="data_criterion" nodeset="instance('criteria_data')/criteria/criterion"/>
.See below a full example with your code, which works fine for me under Orbeon Forms: