tags:

views:

51

answers:

1

If i try to use <xsl:text>&#160;</xsl:text> to add a white space in my xslt code a question mark is displayed after it converted to html. Please help to solve this issue.

Thanks Pradeep

A: 

Probably you shoud explicitly specify the encoding like in the following code:

<xsl:stylesheet version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;
 <xsl:output method="html" encoding="utf-8"/>
 <xsl:template match="node()|@*">
   <xsl:copy>
    <xsl:apply-templates select="node()|@*"/>
   </xsl:copy>
 </xsl:template>

 <xsl:template match="td[not(node())]">
  <xsl:copy>
   <xsl:text>&#160;</xsl:text>
  </xsl:copy>
 </xsl:template>

 <xsl:template match="/">
  <html>
   <head>
   </head>
   <xsl:apply-templates/>
  </html>
 </xsl:template>
</xsl:stylesheet>

When this transformation is applied against this XML document:

<table border="1">
<tr>
 <td>X</td>
 <td></td>
 <td>X</td>
</tr>
</table>

the wanted result is produced and the browser (IE8) displays the hard space correctly:

<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<table border="1">
<tr>
<td>X</td>
<td> </td>
<td>X</td>
</tr>
</table>
</html>
Dimitre Novatchev
Thanks for the reply.. :) Problem solved .
Pradeep
@pradeepadkm: If so, will you, please, accept my answer? :)
Dimitre Novatchev