本文介绍了Orbeon 表单生成器 - 引用部分模板中的控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有许多表单都引用了标题"部分模板.我想从表单中的另一个控件引用此节模板中的控件.(使用此处显示的方法:编写约束以根据在 Orbeon 表单生成器中另一个字段中输入的值验证一个字段)

I have a number of forms that all reference a 'Header' Section Template. I would like to reference a control in this section template from another control in the form. (Using the method shown here: Write constraint to validate a field based on the value entered in another field in Orbeon Form Builder)

当我尝试在节模板中引用名为节"的控件时出现以下错误:

I get the following error when I try to reference a control named 'section' in the section template:

独立表达式中未声明的变量:$section

这是我使用的 XPath 表达式:

Here is the XPath Expression I am using:

if($section = 'PKP' or $section = '') then true() else false()

节模板中有一个名为节"的控件,但它似乎无法从表单的其余部分访问.

There is a control named 'section' in the Section Template, but it appears that it is not accessible from the rest of the form.

有谁知道是否可以在 Orbeon 表单生成器中引用部分模板"中的控件?

Does anyone know if it is possible to reference a control that is in a 'Section Template' in Orbeon form builder?

推荐答案

如您所见,您无法使用命名的 $gaga 访问该部分之外的部分模板字段的值,假设字段名是gaga.这是因为您的表单中可能有同一部分模板的多个实例".假设您有一个地址"部分模板,并在帐单地址"和送货地址"的表单中插入两次.然后,如果在这些部分模板之外使用 $city,您将不知道它是否指的是帐单或送货地址中的 City 字段.

As you noticed, you can't access the value for a field of a section template outside of that section using named $gaga, assuming that the field name is gaga. This is because you could have multiple "instances" of the same section template in your form. Imagine you have an "address" section template, and you insert it twice in the form for the "Billing address" and "Shipping address". Then if using $city outside of those section templates, you wouldn't know if it refers to the City field in the billing or shipping address.

相反,当将部分模板添加到表单时,您需要为这些部分指定一个名称(比如 billing-address)并使用 XPath 表达式,例如 /form/billing-address/city 引用帐单地址中城市字段的值.

Instead, when adding the section template to the form, you'll want to assign a name to those sections (say billing-address) and use an XPath expression such as /form/billing-address/city to reference the value of the city field in the billing address.

这篇关于Orbeon 表单生成器 - 引用部分模板中的控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 05:10