XSLT 用逗号 (,) 连接值 [英] XSLT Concatenating the values with comma (,)
本文介绍了XSLT 用逗号 (,) 连接值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要遍历xml文档中的所有节点并用逗号 ( , ) 附加值最后在最后一个元素之后我不应该有逗号 (,)
i need to loop through all the nodes in the xml document and append the values with comma ( , ) finally after the last element i should not have commma (,)
任何人都可以帮助我.
谢谢你,拉玛娜·库马尔.
thanking you, Ramana kumar.
推荐答案
你可以这样做:
<xsl:for-each select="element">
<xsl:value-of select="whatever" />
<xsl:if test="position() != last()">, </xsl:if>
</xsl:for-each>
position()
函数返回当前元素在 for-each
上下文中的索引,last()
返回索引最后一个元素.
The position()
function returns the index of the current element in the for-each
context, and last()
returns the index of the last element.
使用 xsl:if 的条件处理XSLT 文档的
部分提供了有关此示例的更多信息.
The Conditional Processing with xsl:if
section of the XSLT documentation provides more information about this example.
这篇关于XSLT 用逗号 (,) 连接值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文