[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] outputting &nbsp to HTML (not so final answer)


Subject: Re: [xsl] outputting &nbsp to HTML (not so final answer)
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Mon, 17 Dec 2001 16:12:04 +0000

Hi Aniceto,

> using "<xsl:output method="html"/> + &#160; combination" I can have
> something like "<td> </td>" not "<td>&nbsp;</td>" as desired to
> solve the netscape cell problem

MSXML3 is serializing non-breaking space characters as native
characters (an actual non-breaking space character) rather than using
the HTML character entity reference (&nbsp;).

You can force MSXML3 not to use the native character by telling it to
serialize in an encoding which doesn't include the non-breaking space
character, for example ASCII:

<xsl:output encoding="US-ASCII" />

Unfortunately, MSXML3 does not use the HTML character entity reference
(&nbsp;) even if it can't use the native character, but instead gives
a character reference:

  <td>&#160;</td>

That's as close as you're going to get with MSXML3. Other processors
will use the character entity reference (&nbsp;) in these
circumstances.

But having tested in Netscape 4.74, whether you use a native
character, a character entity reference or a character reference makes
no difference - the table cell is rendered in exactly the same way.
It's only when you look at the source of the result file that you
might think that the native non-breaking space character was a normal
space rather than a non-breaking space.

> I can read in secction 2: "You can even declare nbsp in an internal
> subset of your stylesheet if you want a friendlier representation of
> the character" but I can't guess that it means

It means that you can use a DOCTYPE declaration in your stylesheet to
declare that the entity reference &nbsp; means the non-breaking space
character:

<?xml version="1.0"?>
<!DOCTYPE xsl:stylesheet [
<!ENTITY nbsp '&#160;'>
]>

And then in your stylesheet you can use &nbsp; as much as you want, to
mean a non-breaking space character. However, this does not affect the
way the non-breaking space character is serialized in the result
document. Whether you use:

  <td>&nbsp;</td>
  <td>&#160;</td>
  <td> </td>      (where that 'space' is a non-breaking space)

makes no difference to the XSLT processor.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



Current Thread
Keywords