Re: [xsl] Empty object

Subject: Re: [xsl] Empty object
From: scott gabelhart <swgabel@xxxxxxxxxxxx>
Date: Thu, 29 Jan 2004 10:21:13 -0500
Wendell Piez wrote:

Hi Scott,

At 03:57 PM 1/28/2004, you wrote:

in my final output I need to physically see <td>&nbsp:</td>. Currently my output contains <td>{a single space}</td>. The reason being my OBJECT element is transformed to <td> and the original space needs to be held within the outputed <td>&nbsp;</td>. If you open my current output in IE you will see the famous A where my output contains <td> </td>

By "the famous A" I take it you mean two characters, the A-with-circumflex (a little "hat" on top) followed by a space: "Â " (I paste it in hopes it'll come through).

In fact, this is what Internet Explorer shows when it's looking at a UTF-8 non-breaking space, but it doesn't know the file is in UTF-8, instead construing it in an older encoding (iso-8859-1 or some such).

In other words, you are in fact getting the correct character, only IE is not showing it to you.

Adding an encoding declaration to your output -- perhaps even assuring it's "safe" for IE by using <xsl:output encoding="iso-8859-1"/> (assuming your processor will do that: most will) and thereby writing in a character set that IE can handle, will fix this.

If you really want to post-process your file, or force your post-transformation serializer, to substitute the non-breaking space character with an entity reference (or rather, with a string that will function as such in the serialized output), that can be done. See for example Doing this in XSLT, however, isn't recommended for those who haven't fully grasped the downside of the optional d-o-e feature.

It's far better, and usually much easier, to set up things so that your browser recognizes what character encoding your document is actually in, instead of just guessing wrong.

I might give more details on how to do this, only the whole thing makes my head hurt, and I know there are others on this list who could do a better job of it. But this is the oldest FAQ in the book.


====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================

XSL-List info and archive:


thanks for all the input. Fixed the problem yesterday afternoon.

xml input file

   <!ENTITY nbsp "&#160;">

xsl file
<snippet..with OBJECT template>

<xsl:when test="text() = '&#160;'">
<xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
XHTML output file:

<td style="color:#000000;font-family:Arial;font-size:8pt;text-align:right;background-color:#FFFFFF;height:20px;width:98px;">$4.00</td>
<td style="color:#000000;font-family:Arial;font-size:8pt;text-align:right;background-color:#FFFFFF;height:20px;width:98px;">&nbsp;</td>

- Scott

XSL-List info and archive:

Current Thread