XForms:设置相关从 XML 中删除标签
我有一个下拉菜单,有 2 个选项“上传文件”、“添加 URL”。如果用户选择上传文件,我的表单将显示一个文件选择器。如果用户选择“添加 URL”,表单将隐藏文件选择器并显示一个文本框。我是利用相关性来做到这一点的。
<xforms:bind nodeset="./document" relevant="instance('test')/uploadMethod='Upload File'"/>
<xforms:bind nodeset="./documentURL" relevant="instance('test')/uploadMethod='Add URL'" />
文件选择器会将文件信息添加到文档标签中。文本框数据将保存在 documentURL 标记中。
用户选择上传文件并上传文件并保存 XML。在保存的 XML 中,我不再看到该标签。我有一个用例,其中用户必须能够编辑此 XML,并且他可以选择添加 URL。问题是这样的。由于保存的 XML 不包含标记,因此文本框不会显示在表单上。
有人可以帮忙解决这个问题吗?我需要能够让用户在编辑模式下根据他在下拉列表中选择的内容查看文件选择器或文本框。
I have a drop down with 2 options "Upload File", "Add URL". If user selects Upload file, my form will display a file selector. If user selects Add URL, the form will hide the file selector and instead display a textbox. I have done this using relevancy.
<xforms:bind nodeset="./document" relevant="instance('test')/uploadMethod='Upload File'"/>
<xforms:bind nodeset="./documentURL" relevant="instance('test')/uploadMethod='Add URL'" />
File Selector will add file information to document tag. Textbox data will get saved in documentURL tag.
User chooses to Upload File and uploads a file and saves the XML. In the saved XML, I no longer see the tag. I have a use case where user must be able to edit this XML and he can choose to Add URL. The issue is this. Because the saved XML does not contain the tag, the textbox does not get displayed on the form.
Could anybody please help with this? I need to be able to let the user see the file selecor or textbox based on what he chooses in the dropdown, in edit mode.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果实例中有元素,但在提交实例后它们不再存在,可能是因为您启用了“相关性修剪”,这将从提交的 XML 中删除所有不相关的节点。您可以通过删除
元素上可能具有的relevant="true"
属性来解决此问题。If you have the elements in the instance, but they are not there anymore after the instance is submitted, it might be because you have "relevance pruning" on, which will remove from the submitted XML all the non-relevant nodes. You would solve this by removing the
relevant="true"
attribute you may have on the<xforms:submission>
element.