【问题标题】:Concatenation of values inside repeat nodeset using comma使用逗号连接重复节点集中的值
【发布时间】:2014-05-30 10:20:28
【问题描述】:

我有一个重复节点集,它将打印节点集中的所有值。

我需要用逗号分隔打印它:

one,two,three

但如果我尝试在重复中连接“,”,我将显示为:

one,two,three,

我需要删除值末尾的逗号。

【问题讨论】:

  • 请提供您现在如何做的示例代码。

标签: xml orbeon xforms


【解决方案1】:

您可以在output 中使用choose()

例如,如果您有这个数据模型:

<xf:model>
    <xf:instance>
        <data>
            <foo>one</foo>
            <foo>two</foo>
            <foo>three</foo>
        </data>
    </xf:instance>
</xf:model>

还有这个xf:output

<div>
    <xf:repeat nodeset="foo">
        <xf:output value="choose(following-sibling::foo,concat(.,','),.)"/>
    </xf:repeat>
</div>

你会得到这个输出(可能需要改变 CSS 来显示内联):

one,two,three

注意:在示例中,xf 前缀绑定到 http://www.w3.org/2002/xforms 命名空间。

【讨论】:

  • 感谢您的回答....但这对我不起作用,因为我已经为避免重复值显示为 'foo[not(. = following::foo/. )]' 在重复节点集中....
  • @LavanyaG - 如果我添加重复的foo 元素并将我的节点集更改为nodeset="foo[not(. = following::foo)]",它仍然对我有用。您能否使用节点集编辑您的问题并重复重复您的问题?
猜你喜欢
  • 1970-01-01
  • 2012-10-19
  • 2011-11-04
  • 2011-01-01
  • 1970-01-01
  • 2015-10-25
  • 1970-01-01
  • 1970-01-01
  • 2018-05-04
相关资源
最近更新 更多