Re: [xsl]   in XSL other than d-o-e ?

Subject: Re: [xsl]   in XSL other than d-o-e ?
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Fri, 19 Jul 2002 10:32:47 +0100
Hi Jochen,

> So know I'm wondering if there's an other way using
> &nbsp; in an XSL-Stylesheet without using d-o-e
>
> This is the way I do it right now:
> <xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>
>
> Is there another, much easier way?

The easiest way of getting a non-breaking space into your output is to
use the character reference for a non-breaking space in your
stylesheet. Simply use:

  &#160;

or:

  &#xA0;

When the XSLT processor serialises the result tree as HTML, it will
see the non-breaking space character and serialise it as a
non-breaking space character or as the character reference &#160; or
&#xA0; or as the entity reference &nbsp;. Whichever of those it does,
you'll get a non-breaking space displayed when you view the HTML
document in a browser (so you shouldn't really worry about which it
uses).

If you want to force the processor to use an character or entity
reference (so that you can see the non-breaking space when you view
the source of the output) then tell it to use ASCII encoding:

<xsl:output encoding="ASCII" />

The non-breaking space character isn't in the ASCII character set, so
it has to be output using an entity or character reference.

If you don't want to have &#160; or &#xA0 in your stylesheet, then you
can declare a 'nbsp' entity in its place:

<?xml version="1.0"?>
<!DOCTYPE xsl:stylesheet [
<!ENTITY nbsp '&#160;'>
]>
<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
...
</xsl:stylesheet>

That will enable you to use &nbsp; in the stylesheet whenever you want
a non-breaking space in the output. (But it won't guarantee that
you'll get "&nbsp;" in the output.)

Cheers,

Jeni

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


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


Current Thread