我有一个要求,比如我有3套项目集(A,B和C)需要下拉。并根据如下所示的某些条件选择每个项目集。
<xxforms:variable name="itemset-A-cnt" select="count(instance('data')/nodeA)" />
<xforms:group ref=".[condition for itemset A]">
<xforms:select1 ref="." incremental="true" appearance="minimal">
<xforms:itemset ref="instance('data')/nodeA"> <!--itemset A displayed if some if condition is true-->
<xforms:label ref="@key" />
<xforms:value ref="@key" />
</xforms:itemset>
</xforms:select1>
</xforms:group>
<xxforms:variable name="itemset-B-cnt" select="count(instance('data')/nodeB)" />
<xforms:group ref=".[condition for itemset B]">
<xforms:select1 ref="." incremental="true" appearance="minimal">
<xforms:itemset ref="instance('data')/nodeB"> <!--itemset B displayed if some if condition is true-->
<xforms:label ref="@key" />
<xforms:value ref="@key" />
</xforms:itemseif if t>
</xforms:select1>
</xforms:group>
<xforms:group ref=".[$itemset-A-cnt =0 and $itemset-B-cnt =0]">
<xforms:select1 ref="." incremental="true" appearance="minimal">
<xforms:itemset ref="instance('data')/nodeC"> <!--itemset C displayed if itemset A and B is empty-->
<xforms:label ref="@key" />
<xforms:value ref="@key" />
</xforms:itemset>
</xforms:select1>
</xforms:group>
目前我们如何实现这一目标是使用具有条件集A和项集B的条件的组 对于项目集C.我发现项目集A和B中的值计数使用xxforms:变量将其分配给变量a-cnt和b_cnt,并使用大小检查为项目集C创建了一个组。
逻辑对我有用。但我认为这不是实现这种目标的正确方法。 如果有办法放置类似xxforms的东西:如果在itemset上,那么我可以在一个select1中执行逻辑。
答案 0 :(得分:1)
在XForms中,您可以在xforms:item
或xforms:itemset
中使用的select
或select1
数量没有限制。此外,您可以使用条件控制项目集,例如使用if (condition) then items else ()
。
所以解决方案看起来像:
<xforms:select1>
<xforms:itemset nodeset="if (condition A) then instance('data')/nodeA else ()">
...
</xforms:itemset>
<xforms:itemset nodeset="if (condition B) then instance('data')/nodeB else ()">
...
</xforms:itemset>
<xforms:itemset nodeset="if (condition C) then instance('data')/nodeC else ()">
...
</xforms:itemset>
</xforms:select1>