Re: XT, HTML, and &nsbp;

Subject: Re: XT, HTML, and &nsbp;
From: Ray Waldin <rwaldin@xxxxxxxxxxx>
Date: Fri, 21 May 1999 15:37:18 -0700
Thanks Mike,

Let me see if I understand this correctly:

XML only defines five built-in entity references: &amp;, &lt;, &gt;,
&apos;, and &quot;.

HTML40 defines many more (like &nbsp;).  In order to use HTML40 defined
entity references in XSL documents (not source trees, but in XSL
"scripts"), one must determine the underlying UCS character code, and
use that code in a character reference (&#160;).

The reason why XSL doesn't have something like:

    <xsl:entity-reference>nbsp</xsl:entity-reference>

is that the result tree needs to contain the actual character being
referenced, even though the resulting output will contain the string
"&nbsp;".  The XSL processor has no idea what character is being
referenced unless it parses the result namespace DTD looking for entity
declarations, which it doesn't. 

So why not add these missing entity declarations to the stylesheet?  I'm
using XT and Sun's Project X non-validating parser and I now prefix my
XML to HTML stylesheets with:

    <!DOCTYPE xsl:stylesheet SYSTEM 'Html40EntityDeclsForXml.dtd'>
    <xsl:stylesheet ...

The Html40EntityDeclsForXml.dtd is just an XML version of the entity
references section HTML40 DTD.  This seems to add no more than a couple
of milliseconds processing per stylesheet and let's me use any HTML40
entity reference right in my XSL without having to lookup the character
code myself.  (Yes, I'm that lazy!)

-Ray



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


Current Thread