Search code examples
xmlxsltxslt-1.0xslt-2.0

How to have multiple "To replace" special characters in xsl translate


How can I replace all the dash and dot on my string with a slash? I've tried using the below code.

<xsl:value-of select="translate('string_name', '-.', '/')"/>

I've also tried using the "|" but both codes don't work

<xsl:value-of select="translate('string_name', '-|.|', '/')"/>

Does anyone know a way to do this? Thank you.

I'm expecting to remove all the dots and dashes on my string and be replace by slash.


Solution

  • I think you want:

    <xsl:value-of select="translate('string_name', '-.', '//')"/>
    

    (that is, one replacement character for each character in the string of characters to be replaced).

    And you probably do not want to quote the reference to the input string.