I cannot get the HSSFSerializer working directly from an XMLReader.  I have
used Cocoon 2.0.2  and a few of the development snapshots without sucess.
When I use the TextSerializer, everthing works fine-- (That is, except that
I don't get the desired XLS file!)

Below is my code, and the exception I received.  I am using the poi XML
sample test files included with cocoon.  I was able to easily get cocoon to
output the XLS file using the Cocoon Main command line tool.

import org.xml.sax.helpers.XMLReaderFactory;
import org.apache.cocoon.serialization.HSSFSerializer;
import java.io.*;
import javax.xml.parsers.*;
import org.xml.sax.*;

// The exeption I receive is this:
//  java.lang.NullPointerException
//    at
org.apache.xerces.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:119
3)
//    at ConvertFile.convert(ConvertFile.java:35)
//    at ....
//  And of course... nothing is written to the output file.
//  When I try the newer Xerces version 2.0.1 I get an ElementException of
some sort.

public void convert (String inFile, String outFile)
       throws Exception {
     HSSFSerializer hssf = new HSSFSerializer();
     hssf.setOutputStream (new FileOutputStream (outFile));

     XMLReader reader =
SAXParserFactory.newInstance().newSAXParser().getXMLReader ();
     reader.setContentHandler (hssf);
     reader.parse ( new InputSource (new FileInputStream (inFile)));
}

Different variations that I have tried:
Pentium III, Pentium 4
Windows XP
JDK: 1.3.1_02, 1.4.0
Cocoon 2.0.2   Snapshot:2002.05.31 16.23.28   Snapshot:2002.06.02 16.19.24
Xerces 2.0.0, 2.0.1
Poi 1.2dev, 1.5final


Thank you so much for any help.  I have been pulling my hair out trying to
get this to work!

Micah Schehl


Reply via email to