【问题标题】:concatenate a string/character n number of times in xpath在 xpath 中连接字符串/字符 n 次
【发布时间】:2017-08-25 11:51:03
【问题描述】:

我在我的消息流中使用了一个映射节点,并且有一部分我需要 在 xpath 函数中连接一个字符串/字符 n 次。 有什么办法可以做到这一点 xpath 表达式或 xpath 构建函数(或两者)? 例如:连接 '~' 17 次。

【问题讨论】:

    标签: xpath esb messagebroker


    【解决方案1】:

    简单的 XPath 2.0:

    string-join(for $i in 1 to 17 return '~', '')
    

    在 XPath 3.0 中仍然更容易:

    string-join((1 to 17)!'~')
    

    在 XPath 1.0 中,您最好的选择可能是用 100 个(或许多)波浪号初始化变量 $tildes,然后使用

    substring($tildes, 1, 17) 
    

    【讨论】:

      猜你喜欢
      • 2011-10-11
      • 1970-01-01
      • 2022-11-23
      • 1970-01-01
      • 2018-07-04
      • 1970-01-01
      • 2023-03-31
      • 2021-02-10
      • 2014-03-31
      相关资源
      最近更新 更多