哪个 HTML 标签可用于接受 Orbeon 表单中的动态类名 [英] Which HTML tag can be used to accept dynamic class name in Orbeon Forms
问题描述
我使用 Orbeon Forms 并且我想在 div
或 span
(或任何非 XForms 标签,如 xforms:output
) 以便可以使用该 CSS 类设置控件组.
I use Orbeon Forms and I want to set a dynamic class name on a div
or span
(or any non-XForms tags like xforms:output
) so that group of controls can be set with that CSS class.
<div class="color-with-{if(/fetch/data1='Yes') then 'green' else 'red'}">
但这行不通.当我在呈现表单后查看 HTML 源代码时,它似乎没有处理该动态部分.
But this is not working. When I look at the HTML source code after the form is rendered it seems it did not processed that dynamic part.
<div class="color-with-{if(/fetch/data1='Yes') then 'green' else 'red'}"
id="xf-279">
然而,这种动态分配对于 Orbeon 标签非常有效.
However this dynamic assignment works pretty good with Orbeon tags.
<xforms:output value="if ((xxforms:valid(instance('account-opening-setup'),true()))
and (xxforms:valid(instance('form-variables'),true())))
then 'Complete' else 'Incomplete'"
class="validation-{if ((xxforms:valid(instance('account-opening-setup'),true()))
and (xxforms:valid(instance('form-variables'),true()))) then 'complete'
else 'incomplete'}" />
请告知我可以使用哪个 HTML 标记来动态分配类名,以便控件组遵循该类的 CSS.
Please advise which HTML tag I can use to dynamically assign a class name so that group of controls follow that class CSS.
推荐答案
那些使用 {...XPath...}
语法的表达式被称为 属性值模板 (AVT),Orbeon Forms 在许多 XForms 属性和 HTML 属性中支持它们,包括class
和 style
.所以你上面的代码应该可以工作.
Those expression that use the {...XPath...}
syntax are called attribute value templates (AVT), and Orbeon Forms support them in a number of XForms attributes and HTML attributes, including class
and style
. So your code above should be working.
可能是因为您的 div
不在 XHTML 命名空间中,所以 AVT 没有被解释.我的建议是始终在您的元素上使用前缀.在根元素上定义 xmlns:xhtml="http://www.w3.org/1999/xhtml"
,然后使用 xhtml:div
而不是 >div
.如果您觉得这太不方便,请确保将 XHTML 名称空间作为在根元素上声明的默认名称空间,并使用 xmlns="http://www.w3.org/1999/xhtml"
.
It might be the case that the AVT is not interpreted because your div
isn't in the XHTML namespace. My recommendation is to always use a prefix on your elements. Define the xmlns:xhtml="http://www.w3.org/1999/xhtml"
on the root element, and then use xhtml:div
instead of div
. If you find this too inconvenient, make sure you have the XHTML namespace as your default namespace declared on the root element, with xmlns="http://www.w3.org/1999/xhtml"
.
这篇关于哪个 HTML 标签可用于接受 Orbeon 表单中的动态类名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!