【问题标题】:xslt string replace with substring-afterxslt 字符串替换为 substring-after
【发布时间】:2020-01-28 12:04:14
【问题描述】:

我需要修改如下字段:

<ADDRESS>RieglerhÃtte|27|22|~|~</ADDRESS>RieglerhÃtte 27/22

全部删除~,全部替换| to /(除了第一次出现 | to ' ' 空格)。

我尝试使用翻译功能:

<?substring-before(ADDRESS,‘|‘)?> 
<?translate(translate(substring-after(ADDRESS,‘|‘),‘~|‘,‘/‘),‘|‘,‘/‘)?>

结果为:RieglerhÃtte 27///

也尝试使用替换:

<?xdofx:replace(replace(replace(ADDRESS,'~|',''),'|~',''),'|','/')?>

它工作正常,但在第一次出现 | 后没有空格:RieglerhÃtte/27。 我尝试在替换之前使用 substring-before,但它在 BIP 中给出错误。 (xdofx 和 xdoxslt 不能一起使用)。

我正在尝试获得RieglerhÃtte 27RieglerhÃtte 27/11/22/33 之类的输出(输入为-RieglerhÃtte|27|11|22|33)。

【问题讨论】:

  • 请注意您的解释(“删除所有〜,将所有|替换为/(第一次出现|到''空格除外)。”RieglerhÃtte|27|22|~|~将转换为RieglerhÃtte 27/22//

标签: xslt bi-publisher


【解决方案1】:

我认为你非常接近。假设 ~ 是您的“空白”字符,| 分隔字段,并且您不想显示空白字段...

试试这个:

<?substring-before(ADDRESS,‘|‘)?> 
<?translate(translate(substring-after(ADDRESS,‘|‘),‘|~‘,‘‘),‘|‘,‘/‘)?>

它首先删除空白值,然后将管道分隔符更改为正斜杠。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-03-05
    • 2021-10-10
    • 1970-01-01
    • 1970-01-01
    • 2011-11-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多