You said that:
Quote:
quote:
1. it should not display the strings with some special characters like +,/,=, etc.
2. it should display strings only with characters and _ .
3. if it having any other special characters it should display only ?.
|
From this I understand that you are separating all characters into 3 groups:
1. Those characters in the ASCII set which are niether letters nor digits nor underscore.
2. Those characters in the ASCII set which are letters or digits or underscore.
3. All other characters(potentially in Unicode)
So, my first solution is doing that separation. And I think that you didn't look at the code even before running it: you tried to run it without understanding it. We try to give hints or ideas to help people to accomplish their tasks and sometimes we give whole stylesheets when we think that it's really necessary, and any excerpt or comment is not satisfactory.
Nevertheless, in your last post you say that you need only such strings which don't contain anything except characters in the set you specified. In that case, you must do the following:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<head>
<title></title>
</head>
<body>
<table border="1">
<tr>
<th>Original strings</th>
<th>Filtered strings</th>
</tr>
<xsl:apply-templates select="emp/name"/>
</table>
</body>
</html>
</xsl:template>
<xsl:variable name="allowable-characters" select="'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_'"/>
<xsl:template match="name">
<tr>
<td>
<xsl:value-of select="."/>
</td>
<td>
<xsl:choose>
<xsl:when test="string-length(translate(., $allowable-characters, '')) > 0">?</xsl:when>
<xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
</xsl:choose>
</td>
</tr>
</xsl:template>
</xsl:stylesheet>
Armen