Re: [xsl] differences in methods of inserting a space in HTML produced from XSLT

Subject: Re: [xsl] differences in methods of inserting a space in HTML produced from XSLT
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Tue, 22 Jan 2002 12:14:43 -0500
At 2002-01-22 11:48 -0500, Saverio Perugini wrote:
What are the differences in the following methods of inserting a space into
an HTML file produced from an XML file and XSLT template with
<xsl:output method="html"/>?

<xsl:text disable-output-escaping="yes">&#xA;</xsl:text>

<xsl:text disable-output-escaping="yes">&amp;#xA;</xsl:text>

<xsl:text disable-output-escaping="yes">&amp;#160;</xsl:text>

<xsl:text disable-output-escaping="yes">&amp;nbsp;</xsl:text>

All produce the desired output just fine.

But you are using a feature of XSLT that is not required to be supported by a processor:


Ref. 16.4:

An XSLT processor is not required to support disabling output escaping.

What are the consequences of using each?

Someone using your stylesheet may not be using a processor that supports the attribute you've chosen to use. The consequence is that they will get that text as visible text in their result.


Is there a preferred/correct method?

None of the above.


Use &#160; or &#xA0; or &#xa0; (note your typos above) in your stylesheet and let the XSLT processor recognize the HTML output method and put out &nbsp; if it chooses to. Even if it doesn't choose to, it will still put out a character acceptable to user agents.

If you *really* want to see &nbsp; in your stylesheet, then create an entity declaration in the internal declaration subset of your stylesheet.

I hope this helps.

......................... Ken


-- Upcoming: 3-days XSLT/XPath and/or 2-days XSLFO - Feb 18-22, 2002

G. Ken Holman                mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd.         http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (Fax:-0995)
ISBN 0-13-065196-6                        Definitive XSLT & XPath
ISBN 1-894049-08-X  Practical Transformation Using XSLT and XPath
ISBN 1-894049-07-1               Practical Formatting Using XSLFO
XSL/XML/DSSSL/SGML/OmniMark services, books(electronic, printed),
articles, training(instructor-live,Internet-live,web/CD,licensed)
Next public training:  02-02-11,12,14,15,18,21,03-04,05,06,08,11,
-                                04-08,09,10,12,05-14,15,06-04,07


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



Current Thread