3

how to remove hyphen from string like "19650512-0065" to "196505120065"

using this template : passing theID =

   <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> 
3
  • Try replacing the xsl:variable and entire xsl:choose with <xsl:value-of select="translate($theID,'-','')"/> Commented Jul 20, 2016 at 13:26
  • 3
    @DanielHaley you should make that an answer not a comment. Commented Jul 20, 2016 at 13:58
  • @MichaelKay - I'm always wary of adding answers when I can't test them, especially from my phone, but I suppose this one is simple enough I can risk it :-) Commented Jul 20, 2016 at 14:04

1 Answer 1

5

Try replacing the xsl:variable and entire xsl:choose with:

<xsl:value-of select="translate($theID,'-','')"/>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.