When I tried with a more complicated XML, then I encountered many problems with Martin Honnen's solution, it doesn't work with the below mentioned XML, so I prepared my own solution refering to Dimitre's this answer
And also I could call it a more efficient solution:
Here is an input xml:
<root>
<string>aabcdbcd1abcdefghijklmanopqrstuvwxyzabcdefgh0123456789ijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz12312489796453134049446798421230156489413210315487804210313264046040489789789745648974321231564648971232344</string>
<string2>oejrinsjfojofjweofj24798273492jfakjflsdjljk</string2>
</root>
And here is the Working XSLT code:
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="text()">
<xsl:call-template name="unique_chars">
<xsl:with-param name="input" select="."/>
</xsl:call-template>
</xsl:template>
<xsl:template name="unique_chars">
<xsl:param name="input"/>
<xsl:variable name="c">
<xsl:value-of select="substring($input, 1, 1)"/>
</xsl:variable>
<xsl:choose>
<xsl:when test="not($input)"/>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="contains(substring($input, 2), $c)">
<xsl:call-template name="unique_chars">
<xsl:with-param name="input" select="substring($input, 2)"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$c"/>
<xsl:call-template name="unique_chars">
<xsl:with-param name="input" select="substring($input, 2)"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>