[jdom-interest] Tranforming   into hatted A

David M. Karr dmkarr at earthlink.net
Sun Mar 17 20:42:55 PST 2002

>>>>> "Eric" == Eric Sirois <easirois at ca.ibm.com> writes:

    Eric> David M. Karr wrote:

    >> I did go over the XSLT FAQ about special characters, but I didn't see anything
    >> obviously covering this.
    >> I'm trying to figure out how to generate a "&nbsp;" element in my HTML output.
    >> Unfortunately, it only produces a capital "hatted A".  I also tried an explicit
    >> "&#160;", but that did the same thing.  I tried to trick it with "&amp;nbsp;",
    >> but the result was uninspiring, being exactly "&amp;nbsp;".
    >> What exactly is happening here?

    Eric> Hello David,
    Eric> This happens when your transformed document is in UTF-8 encoding and the
    Eric> browser is usally set to ISO-8859-1/Windows 1252.  There are three things you
    Eric> can do.

    Eric> 1) Change your browser's default encoding to UTF-8
    Eric> 2) use <xsl:output  method="html" encoding="iso-8859-1"> in your stylesheet
    Eric> 3) use iso-8859-1 encoding in your XML document

In my environment, using JDOM/JAXP, I'm finding that nothing I do to try to set
the output encoding to "iso-8859-1" has any effect on the character encoding of
my output document.  I have a feeling this is just a JAXP issue, and not with
JDOM, however.  I was able to get these characters to view correctly in the
browser by changing the browser to UTF-8 (your thing 1), but things 2 and 3 had
no effect on the output document or how it views in the browser (when the
browser is using "auto-detect" or "iso-8859-1").

I'm going to proceed with building a JAXP-only test case for this.

David M. Karr          ; Java/J2EE/XML/Unix/C++
dmkarr at earthlink.net

More information about the jdom-interest mailing list