Reputation: 57
I created a function to replace commas and dashes with a space, the issue is the it is removing the comma and dashes but it is not replacing it with the dash.
For example I have a user last name Smith-Jones when the transformation is processed I end up with SmithJones not Smith Jones.
My function is:
<xsl:function name="this:prepareText">
<xsl:param name="input-String"/>
<xsl:value-of select="normalize-space(translate(($input-String),',-', ' '))"/>
</xsl:function>
Seems like I must be missing something small here, any help would be great.
Upvotes: 1
Views: 876
Reputation: 111521
The comma case was actually probably working correctly because the third argument to translate
contains a space in the first character position (corresponding to ,
-- comma), but the dash case wouldn't be because there is no second replacement character, so dash would be replaced by nothing.
Just add another space to the third argument of translate
and it'll work fine:
<xsl:value-of select="normalize-space(translate(($input-String),',-', ' '))"/>
Upvotes: 2