Thursday, July 28

XSLT - Remove Special Characters Function

Remove Special Characters Function


Which ever characters are allowed, provide it in the select. Anything other than provided characters will be considered as special characters.

<xsl:function name="stripSpecialChars">
    <xsl:param name="string" />
    <xsl:variable name="AllowedSymbols" select ="'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789()*%$#@!~&lt;&gt;,.?[]=- +   /\ '"/>
    <xsl:value-of select="translate($string,translate($string, $AllowedSymbols, ''),' ')"/>
</xsl:function>


<xsl:value-of select="stripSpecialChars($string)"/>


For your information -

&lt;  ---> Less Than Symbol
&gt; ---> Greater Than Symbol

No comments:

Post a Comment