查找最后一个翻译



我有以下xml:

<item>value 1,value 2,value3,</item>

我现在想通过xslt的输出实现以下内容:

<item>value 1,value 2,value3</item>

所以去掉最后一个逗号。你能帮我吗?

使用此模板:

<xsl:template match="item">
<xsl:copy>
<xsl:choose>
<xsl:when test="substring(.,string-length(.))=','">
<xsl:value-of select="substring(.,1,string-length(.)-1)"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="node()"/>
</xsl:otherwise>      
</xsl:choose>
</xsl:copy>
</xsl:template>

只有当最后一个字符是逗号时,它才会删除它。

相关内容

最新更新