The same document parsed with an old version of POI (containing the serializer, before it was integrated in cocoon).
-----Message d'origine----- De : Andrew C. Oliver [mailto:[EMAIL PROTECTED]] Envoy� : mercredi 31 juillet 2002 14:09 � : POI Users List Objet : Re: HSSFSerializer / Null Pointer exception Does the same document parse when using the HSSFSerializer inside of cocoon? This may be a missing element. The Serializer doesn't have great error reporting. PLISSON S�bastien (DSIT-XS/I) wrote: >Hi, > >When i try to use the HSSFSerializer from java, using an XMLReader, >i get a NullPointer Exception when i use the parse function. > >I use POI, Xerces and xalan from cocoon 2.0.3 distribution. >All is deployed on Websphere 3.5.6. > >Any idea how to solve this problem ? > >Thanks. >Seb > >Here is my code : > >/ Output XML to XLS > // > // Instantiate a TransformerFactory. > javax.xml.transform.TransformerFactory tFactory = > >javax.xml.transform.TransformerFactory.newInstance(); > // Verify that the TransformerFactory implementation you are >using > // supports SAX input and output (Xalan-Java does!). > if >(tFactory.getFeature(javax.xml.transform.sax.SAXSource.FEATURE) && > >tFactory.getFeature(javax.xml.transform.sax.SAXResult.FEATURE)) > { > //System.out.println("sauveXMLToXLS - Debut >transformation"); > // Cast the TransformerFactory to SAXTransformerFactory. > javax.xml.transform.sax.SAXTransformerFactory saxTFactory >= > >((javax.xml.transform.sax.SAXTransformerFactory) tFactory); > // Create a Templates ContentHandler to handle parsing of >the > // stylesheet. > javax.xml.transform.sax.TemplatesHandler templatesHandler >= > >saxTFactory.newTemplatesHandler(); > > // Create an XMLReader and set its ContentHandler. > org.xml.sax.XMLReader reader = > >org.xml.sax.helpers.XMLReaderFactory.createXMLReader(); > reader.setContentHandler(templatesHandler); > > // Parse the stylesheet. > reader.parse(xslFilename); > > // Get the Templates object (generated during the parsing >of the stylesheet) > // from the TemplatesHandler. > javax.xml.transform.Templates templates = > >templatesHandler.getTemplates(); > // Create a Transformer ContentHandler to handle parsing >of > // the XML Source. > javax.xml.transform.sax.TransformerHandler >transformerHandler > = >saxTFactory.newTransformerHandler(templates); > // Reset the XMLReader's ContentHandler to the >TransformerHandler. > reader.setContentHandler(transformerHandler); > > // Set the ContentHandler to also function as a >LexicalHandler, which > // can process "lexical" events (such as comments and >CDATA). > >reader.setProperty("http://xml.org/sax/properties/lexical-handler", > >transformerHandler); > > // Set up a Serializer to serialize the Result to a file. > HSSFSerializer ser = new HSSFSerializer(); > ser.setOutputStream(xlsFile); > > //org.apache.cocoon.serialization.XMLSerializer ser = new >org.apache.cocoon.serialization.XMLSerializer(); > //ser.setOutputStream(System.out); > > // The Serializer functions as a SAX ContentHandler. > javax.xml.transform.Result result = > new >javax.xml.transform.sax.SAXResult((org.xml.sax.ContentHandler)ser); > transformerHandler.setResult(result); > > // Parse the XML input document. > reader.parse(xmlFilename); // Here i get NullPointer >Exception > >-- >To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> >For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> > > > > -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
