如何让 XForm 显示复选框?

发布于 2024-08-13 18:37:20 字数 490 浏览 5 评论 0原文

我似乎在让 xform 显示复选框时遇到问题 - 相反,它显示的是文本区域。我的所有其他项目都工作正常,我只是似乎无法让这个项目工作。

这是我的模型中的代码:

<takeMoneyOff type="xs:boolean"/>

// close the my structure
// close the instance

<xf:bind id="takeMoneyOff" nodeset="/xForm/takeMoneyOff"/>

// close the model

而这一切所指的显示项目是:

<xf:input ref="takeMoneyOff" class="takeMoneyOffClass">
    <xf:label>Take Money Off? </xf:label>
</xf:input>

I seem to be having problems getting a xform to display a check box -- instead it is displaying a text area. All my other items are working correctly, I just can't seem to get this one to work.

This is the code inside my model:

<takeMoneyOff type="xs:boolean"/>

// close the my structure
// close the instance

<xf:bind id="takeMoneyOff" nodeset="/xForm/takeMoneyOff"/>

// close the model

And the item this is all referring to for display is:

<xf:input ref="takeMoneyOff" class="takeMoneyOffClass">
    <xf:label>Take Money Off? </xf:label>
</xf:input>

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

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

发布评论

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

评论(2

听,心雨的声音 2024-08-20 18:37:20

您没有提及您所针对的 XForms 实现,但假设它是/它们完全一致,您有两个选择。

  1. 如果要指定实例数据中的类型(如示例代码所示),则需要将 type 属性置于 XML 架构实例命名空间中。因此,如果您已声明命名空间前缀 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance",您的实例数据将需要如下所示:< /p>

    >
    
  2. < p>或者,如果实例数据来自外部源并且您无法控制它,那么您可以在绑定元素本身上放置一个 type 属性(在这种情况下,它不应该位于 xsi 命名空间中) :

    />
    

You don't mention which XForms implementation(s) you are targeting, but assuming that it is / they are fully conformant, you have two options.

  1. If you want to specify the type in the instance data, as your example code indicates, you need the type attribute to be in the XML schema instance namespace. So, if you've declared the namespace prefix xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance", your instance datum would need to look like this:

    <takeMoneyOff xsi:type="xs:boolean" />
    
  2. Alternatively, if the instance data is coming from an external source and you're not in control of it, then you can place a type attribute on the bind element itself instead (it should not be in the xsi namespace in this case):

    <xf:bind id="takeMoneyOff" nodeset="/xForm/takeMoneyOff" type="xs:boolean" />
    
热情消退 2024-08-20 18:37:20

您还可以使用 ,它将存储值或空白:

<xf:select ref="takeMoneyOff" class="takeMoneyOffClass">
    <xf:label>Take Money Off? </xf:label>
    <xf:item>
        <xf:label>Yes</xf:label>
        <xf:value>true</xf:value>
    </xf:item>
</xf:select1>

通过适当的绑定,您甚至可以在出现空白时存储“false”:

<xf:bind id="takeMoneyOff" nodeset="/xForm/takeMoneyOff"
         calculate="choose(. = 'true', ., 'false')"
         readonly="false()"/>

You can also use <xforms:select>, which will store a value or blank:

<xf:select ref="takeMoneyOff" class="takeMoneyOffClass">
    <xf:label>Take Money Off? </xf:label>
    <xf:item>
        <xf:label>Yes</xf:label>
        <xf:value>true</xf:value>
    </xf:item>
</xf:select1>

With the appropriate bind, you could even store "false" when a blank appears:

<xf:bind id="takeMoneyOff" nodeset="/xForm/takeMoneyOff"
         calculate="choose(. = 'true', ., 'false')"
         readonly="false()"/>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文