character entities in xsl(t) - specifically  

Subject: character entities in xsl(t) - specifically  
From: Jerry Ventura <jventura@xxxxxxxxxxxxxx>
Date: Wed, 19 Apr 2000 15:19:33 -0400
Hi,

I have a question about using character entities in xsl - specifically
&nbsp;
I've seen previous posts about this, but I couldn't find a resolution (sorry
if this is a dupe).

Here's the setup - my xsl is pretty simple:

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:output method="html" />
<xsl:template match="*|/"><xsl:apply-templates/></xsl:template>
<xsl:template match="text()|@*"><xsl:value-of select="."/></xsl:template>

<xsl:template match="/">
<HTML>
  <HEAD/>
  <BODY>
    <H1>&nbsp; Some text</H1>
  </BODY>
</HTML>
</xsl:template>
</xsl:stylesheet>

When I run this through a xslt processor (I'm using saxon 5.2), I get the
following error (I didn't attach the xml, I think its irrelevant in my
example):

D:\thinclient\src\html>java com.icl.saxon.StyleSheet req.xml sample1.xsl
Fatal error reported by XML parser: reference to undeclared entity (found
"nbsp"
)
  URL:    file:/D:/thinclient/src/html/sample1.xsl
  Line:   16
  Column: 13
Error preparing style sheet
reference to undeclared entity (found "nbsp")


So I change the nbsp in my xsl to #160, and all is well. The processor
converts #160 to nbsp, and my html is what I expect.


My question (finally) is:

Am I required to use #160 instead of nbsp in my xsl? For some reason, I get
the feeling that I can set the character entity set 

<!ENTITY % HTMLlat1 PUBLIC "-//W3C//ENTITIES Latin 1//EN//HTML"> %HTMLlat1;

and take advantage of <!ENTITY nbsp   CDATA "&#160;">. This way I don't have
to change nbsp. Am I way off the mark here? Could someone post an example,
or shed some light?

Thanks

 - Jerry


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


Current Thread