如何在xslt中的所需位置替换特殊字符?
这是我的xml:
<block4>
<tag>
<name>5</name>
<value>accnt number
Name
Address1
Address2
Address3</value>
</tag>
</block4>
这是我当前的xslt逻辑:
<xsl:for-each select ="block4/tag[name = '5']">
<xsl:variable name ="del50k" select ="(translate(substring-after(value,' '),' ','~'))"/>
<xsl:value-of select="concat(substring-before(value,' '), ',',$del50k)" />
</xsl:for-each>,<xsl:text/>
输出我的逻辑:
accnt number,Name~Address1~Address2~Address3,
但要求的输出是
accnt number,Name~Address1 Address2 Address3,
tidle分隔符应仅在name
和address1
之间,address
应遵循规范化空格。
任何人都可以帮我解决这个问题吗?
答案 0 :(得分:2)
这应该有效!
<xsl:for-each select ="block4/tag[name = '5']">
<xsl:variable name ="del50k" select ="concat(substring-before(substring-after(value,' '),' '),'~',substring-after(substring-after(value,' '),' '))"/>
<xsl:value-of select="concat(substring-before(value,' '), ',',$del50k)" />
</xsl:for-each>,<xsl:text/>