【发布时间】:2016-07-20 13:21:06
【问题描述】:
如何从“19650512-0065”到“196505120065”等字符串中删除连字符
使用此模板:传递 ID =
<xsl:template name="unformatLFPartyID">
<xsl:param name="theID" select="." />
<xsl:variable name="idSuffix" select="string-length($theID) - 3" />
<xsl:choose>
<xsl:when test="contains($theID,'-')">
<xsl:value-of select="substring($theID,0,$idSuffix)" />
<xsl:value-of select="substring($theID, $idSuffix)" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$theID" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
【问题讨论】:
-
尝试将 xsl:variable 和整个 xsl:choose 替换为
<xsl:value-of select="translate($theID,'-','')"/> -
@DanielHaley 您应该将其作为答案而不是评论。
-
@MichaelKay - 当我无法测试它们时,我总是对添加答案持谨慎态度,尤其是通过我的手机,但我想这个很简单,我可以冒险:-)