XForms 绑定元素错误

发布于 2024-09-04 03:02:17 字数 1377 浏览 5 评论 0原文

我正在更改代码以在 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 技术交流群。

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

发布评论

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

评论(1

如果没有 2024-09-11 03:02:17

您可能需要更改一些内容:

  1. 不确定这是否是错误的原因,但 nodeset 表达式应该是 instance('criteria_data')/criteria/...< /code>,没有文件。请记住:instance() 返回根元素,而不是文档节点。 (您通过更新问题来处理这个问题;很好)
  2. 您在 bind 上缺少 xf 。它应该是:

请参阅下面包含您的代码的完整示例,该示例在 Orbeon Forms 下对我来说效果很好:

<xhtml:html xmlns:xhtml="http://www.w3.org/1999/xhtml"
      xmlns:xforms="http://www.w3.org/2002/xforms"
      xmlns:xf="http://www.w3.org/2002/xforms"
      xmlns:xxforms="http://orbeon.org/oxf/xml/xforms"
      xmlns:ev="http://www.w3.org/2001/xml-events"
      xmlns:xs="http://www.w3.org/2001/XMLSchema"
      xmlns:fr="http://orbeon.org/oxf/xml/form-runner">
    <xhtml:head>
        <xhtml:title>SO Bind</xhtml:title>
        <xf:model id="select_data">

            <xf:instance id="criteria_data" xmlns="">
                <file>
                    <criteria>
                        <criterion>Gaga</criterion>
                    </criteria>
                </file>
            </xf:instance>
            <xf:bind id="data_criterion" nodeset="instance('criteria_data')/criteria/criterion"/>
       </xf:model>

    </xhtml:head>
    <xhtml:body>
        <xf:input bind="data_criterion">
            <xf:label>Enter criteria:</xf:label>
        </xf:input>
    </xhtml:body>
</xhtml:html>

A couple of things you might want to change:

  1. Not sure of this is the reason for the error, but the nodeset expression should be instance('criteria_data')/criteria/..., without file. Remember: instance() returns the root element, not the document node. (This one you took care by updating the question; good)
  2. You are missing the xf on the bind. 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:

<xhtml:html xmlns:xhtml="http://www.w3.org/1999/xhtml"
      xmlns:xforms="http://www.w3.org/2002/xforms"
      xmlns:xf="http://www.w3.org/2002/xforms"
      xmlns:xxforms="http://orbeon.org/oxf/xml/xforms"
      xmlns:ev="http://www.w3.org/2001/xml-events"
      xmlns:xs="http://www.w3.org/2001/XMLSchema"
      xmlns:fr="http://orbeon.org/oxf/xml/form-runner">
    <xhtml:head>
        <xhtml:title>SO Bind</xhtml:title>
        <xf:model id="select_data">

            <xf:instance id="criteria_data" xmlns="">
                <file>
                    <criteria>
                        <criterion>Gaga</criterion>
                    </criteria>
                </file>
            </xf:instance>
            <xf:bind id="data_criterion" nodeset="instance('criteria_data')/criteria/criterion"/>
       </xf:model>

    </xhtml:head>
    <xhtml:body>
        <xf:input bind="data_criterion">
            <xf:label>Enter criteria:</xf:label>
        </xf:input>
    </xhtml:body>
</xhtml:html>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文