Re: [xsl] Empty object

Subject: Re: [xsl] Empty object
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Wed, 28 Jan 2004 17:35:28 -0500
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 http://www.xml.com/pub/a/2003/01/02/xmlchar.html. 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.

Cheers,
Wendell


====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 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: http://www.mulberrytech.com/xsl/xsl-list



Current Thread