cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sven Kuenzler <sv...@imost.de>
Subject Re: TR: HSSFSerializer / Null Pointer exception
Date Thu, 01 Aug 2002 07:45:25 GMT
You have to initialize the logging. See

www.tzi.de/~svenk/poimorpher.zip

for an example how to use the serializer w/o Cocoon.
Or even better, checkout the new Morphos project in Jakarta commons sandbox.

	Sven

PLISSON Sébastien (DSIT-XS/I) schrieb:
> 
>> -----Message d'origine-----
>>De : 	PLISSON Sébastien (DSIT-XS/I)  
>>Envoyé :	jeudi 1 août 2002 08:11
>>À :	cocoon-users@xml.apache.org
>>Objet :	HSSFSerializer / Null Pointer exception
>>
>>
>>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
>>
>>
>>Sébastien PLISSON
>>DSIT XS / Infocentre
>>Tél. : 30.13.90
>>
> 
> 
> ---------------------------------------------------------------------
> Please check that your question  has not already been answered in the
> FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>
> 
> To unsubscribe, e-mail:     <cocoon-users-unsubscribe@xml.apache.org>
> For additional commands, e-mail:   <cocoon-users-help@xml.apache.org>
> 
> 





---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <cocoon-users-unsubscribe@xml.apache.org>
For additional commands, e-mail:   <cocoon-users-help@xml.apache.org>


Mime
View raw message