简体   繁体   English

XSL-用其他字符替换管道

[英]XSL - Replace pipe by another character

I use XSLT 2. How I can replace pipe by aonther character ? 我使用XSLT2。如何用其他字符替换管道?

For exemple I have an element like this : 例如,我有一个像这样的元素:

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

I want to have 我希望有

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

I tried something like this, but not working 我尝试过类似的方法,但是没有用

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

What is problem ? 有什么问题?

The replace() function uses regex - and the pipe character is a special character in regex. replace()函数使用正则表达式-管道字符是正则表达式中的特殊字符。 Either escape the character: 逃脱字符:

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

or use the translate() function instead. 或改为使用translate()函数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM