【问题标题】:XSL - Replace pipe by another characterXSL - 用另一个字符替换管道
【发布时间】:2019-04-30 13:03:28
【问题描述】:

我使用 XSLT 2。如何用另一个字符替换管道?

例如,我有一个这样的元素:

<list items="A1|A2|A3"/>

我想拥有

<list items="A1,A2,A3"/>

我尝试了类似的方法,但没有工作

<xsl:variable name="result" select="replace(list/@items, '|', ',')"/>

什么问题?

【问题讨论】:

    标签: xslt xslt-2.0 oxygenxml


    【解决方案1】:

    replace() 函数使用正则表达式 - 管道字符是正则表达式中的特殊字符。要么转义字符:

    <xsl:variable name="result" select="replace(list/@items, '\|', ',')"/>
    

    或改用translate() 函数。

    【讨论】:

      猜你喜欢
      • 2020-02-08
      • 2013-12-03
      • 2011-11-14
      • 1970-01-01
      • 2019-05-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-21
      相关资源
      最近更新 更多