You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Scott Boag/CAM/Lotus <Sc...@lotus.com> on 2000/01/18 08:24:05 UTC

Re: NullPointerException in org.apache.xalan.xpath.xml.FormatterToXML .init()

Hi Lewis.  Yes, you should definitely send me a note direct, or post on the
xalan-dev list (see http://xml.apache.org/mail.html if you are not already
signed up).  We are struggling with support right now, and I don't get a
chance to review the AlphaWorks discussion as often as I would like.

Ugh... VM differences with encoding strike again.

> 1. The key "UTF-8" needs to be added to the s_revhash table, and

I will do this, but what worries me is what if the file.encoding System
property returns something like ISO-8859-3??  What system are they using?

> 2. getMimeEncoding() should be made to always return either "UTF-8"
> or "UTF-16", even if convertJava2MimeEncoding() returns null.

Yep, it's supposed to, but I guess I missed.  I changed:

          if(null != jencoding)
            encoding = jencoding;

to:

          encoding = (null != jencoding) ? jencoding :
DEFAULT_MIME_ENCODING;

which should do the trick.

I cc'd this to the xalan-dev list, which I assume should be OK since you
already posted on the LotusXSL discussion list on AlphaWorks.

-scott




                                                                                                                   
                    "Schoenberg,                                                                                   
                    Lewis"               To:     "Scott Boag (E-mail)" <Sc...@lotus.com>            
                    <lew@hq.ileaf        cc:                                                                       
                    .com>                Subject:     NullPointerException in                                      
                                         org.apache.xalan.xpath.xml.FormatterToXML .init()                         
                    01/17/00                                                                                       
                    01:21 PM                                                                                       
                                                                                                                   
                                                                                                                   




Scott -

I posted the following today on the LotusXSL discussion list.  I'm sending
it to you as well in order to cover all bases.

Thanks,
Lewis


I've encountered the following problem with LotusXSL 0.19.1, on
Windows using Microsoft wjview, when processing an XSL file containing
an xsl:output element with method="html" and no encoding attribute.
This problem does not occur when the encoding="UTF-8" attribute is
present on the xsl:output element, or when running with Microsoft
jview instead of wjview:

The method init( OutputStream output, OutputFormat format ), in the
class org.apache.xalan.xpath.xml.FormatterToXML, is throwing a
NullPointerException when attempting to reference the m_encoding field.

The root cause to which I have tracked down this problem is that the
"file.encoding" Java System property under wjview is "utf-8" and this
is not a key in FormatterToXML's s_revhash Hashtable. (The problem
does not occur under jview because jview's file.encoding property is
"Cp1252", which is a key in the s_revhash).

A secondary cause of the exception is that the method
convertJava2MimeEncoding(String encoding) returns null, instead of a
reasonable value, when it encounters an unexpected file.encoding
property.

Unfortunately, I have not been able to get a stack trace because of a
weirdness in my debugger. Hopefully the following detail will prove
helpful:

In init( OutputStream output, OutputFormat format ), the call to
getMimeEncoding(format.getEncoding()) is returning null and the null
is being assigned to m_encoding. getMimeEncoding(String) returns null
because the file.encoding System property, when running wjview, is
"utf-8", and this is not one of the encodings that
getMimeEncoding(String), or the method that it calls,
convertJava2MimeEncoding(String), handles. The s_revhash hashtable
contains the key "UTF8" but not "UTF-8", so the call,
(String)s_revhash.get(encoding.toUpperCase()), in
convertJava2MimeEncoding(String encoding), returns null.

I believe that:

1. The key "UTF-8" needs to be added to the s_revhash table, and

2. getMimeEncoding() should be made to always return either "UTF-8"
or "UTF-16", even if convertJava2MimeEncoding() returns null.

This will ensure that the following requirement from Section 16.1 of
the XSLT recommendation is fulfilled:

"If no encoding attribute is specified, then the XSLT processor should
use either UTF-8 or UTF-16."