Forum Moderators: open
Until today we where happily using   as a replacement for the in all our XSLTs, that is until a client in china tried to view the output and got a mangled mess of bizarre characters. Some research led us to find that no ASCII character higher than 127 should be used in an HTML document so that's   out the window (which XSLT outputs as an ASCII character (160) that looks like a normal space but behaves like an ).
So we tried using the following:
<xsl:text disable-output-escaping="yes">&nbsp;</xsl:text>
Which worked a treat until it was thrown through one of our display templates. Our display templates kind of act like a picture frame and uses copy of to draw out the picture (some HTML passed as a parameter):
eg:
<xsl:template name="pictureframe">
<xsl:param name="title"/>
<xsl:param name="html"/>
<table>
<tr>
<td><xsl:copy-of select="$title"/></td>
</tr>
<tr>
<td>
<xsl:copy-of select="$html"/></td>
</td>
</tr>
</table>
</xsl:template><xsl:call-template name="pictureframe">
<xsl:with-param name="title">
<b>Title</b>
</xsl:with-param>
<xsl:with-param name="html">
<b>This</b> is the content!
</xsl:with-param>
</xsl:call-template>
The real template is a bit more complicated but we've found this a great way of creating re-usable html templates. Our previous (from
<xsl:text disable-output-escaping="yes">&nbsp;</xsl:text>) now outputs &nbsp; to the HTML. Very frustrating!
We've tried every possible combination of output-escaping on or off and more, even <![CDATA[]]> section seem to have no effect.
Any ideas? Please help!
I spent a number of hours banging my head against this one and never did find the solution. So you aren't alone here. If you do find a solution, I really would like to hear it.
It's both pleasing and disappointing at the same time to find I'm not going nuts on this one! I'll be sure to report in if I ever solve it.
The whole thing has got me thinking though....
When the output method is set to html then an & inside <script> tags does pop out as an & (as required). However, what do you do when you want to create an xhtml document?
I'm guessing the output method should be xml (as xhtml is not a valid option), but then the & would appear as an & inside script tags and therefore you'd be unable to use the && operator in JavaScript.