Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > i get this exception when I try to generate xml file

Reply
Thread Tools

i get this exception when I try to generate xml file

 
 
ab2305@gmail.com
Guest
Posts: n/a
 
      02-05-2006
this is my method (followed by exception):

public void generateXML(String fileName, BookInfoBean bookInfo){
try{
DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance( );

DocumentBuilder parser = factory.newDocumentBuilder( );
Document doc = parser.newDocument();
Node root = doc.createElement(AmazonConstants.BOOKINFO);
doc.appendChild(root);

Node asin = doc.createElement(AmazonConstants.ASIN);
root.appendChild(asin);
asin.appendChild(doc.createTextNode(bookInfo.getAs in()));

Node title= doc.createElement(AmazonConstants.TITLE);
root.appendChild(title);
title.appendChild(doc.createTextNode(bookInfo.getT itle()));

Node rank= doc.createElement(AmazonConstants.SALESRANK);
root.appendChild(rank);

rank.appendChild(doc.createTextNode(bookInfo.getSa lesRank()));

//create/save the actual file.
final Transformer
transformer=TransformerFactory.newInstance().newTr ansformer();

final DocumentType doctype = doc.getDoctype();
if (doctype != null)
{

transformer.setOutputProperty(OutputKeys.DOCTYPE_P UBLIC,
doctype.getPublicId());

transformer.setOutputProperty(OutputKeys.DOCTYPE_S YSTEM,doctype.getSystemId());
}


transformer.transform(new DOMSource(doc),new
StreamResult(new FileOutputStream(fileName)));


} catch (Exception ex) {
System.err.println(ex.getClass( ));
System.err.println(ex.getMessage( ));
ex.printStackTrace();
}


---------------------exception
ERROR: ''
class javax.xml.transform.TransformerException
java.lang.NullPointerException
javax.xml.transform.TransformerException:
java.lang.NullPointerException
at
com.sun.org.apache.xalan.internal.xsltc.trax.Trans formerImpl.transform(Unknown
Source)
at
com.sun.org.apache.xalan.internal.xsltc.trax.Trans formerImpl.transform(Unknown
Source)
at
com.touchgraph.amazoncache.io.CacheStore.generateX ML(CacheStore.java:14
at
com.touchgraph.amazoncache.io.AmazonCacheEngine.ma in(AmazonCacheEngine.java:1
Caused by: java.lang.NullPointerException
at
com.sun.org.apache.xml.internal.serializer.ToUnkno wnStream.characters(Unknown
Source)
at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2T O.parse(Unknown
Source)
at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2T O.parse(Unknown
Source)
at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2T O.parse(Unknown
Source)
at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2T O.parse(Unknown
Source)
at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2T O.parse(Unknown
Source)
at
com.sun.org.apache.xalan.internal.xsltc.trax.Trans formerImpl.transformIdentity(Unknown
Source)
... 4 more
---------
java.lang.NullPointerException
at
com.sun.org.apache.xml.internal.serializer.ToUnkno wnStream.characters(Unknown
Source)
at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2T O.parse(Unknown
Source)
at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2T O.parse(Unknown
Source)
at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2T O.parse(Unknown
Source)
at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2T O.parse(Unknown
Source)
at com.sun.org.apache.xalan.internal.xsltc.trax.DOM2T O.parse(Unknown
Source)
at
com.sun.org.apache.xalan.internal.xsltc.trax.Trans formerImpl.transformIdentity(Unknown
Source)
at
com.sun.org.apache.xalan.internal.xsltc.trax.Trans formerImpl.transform(Unknown
Source)
at
com.sun.org.apache.xalan.internal.xsltc.trax.Trans formerImpl.transform(Unknown
Source)
at
com.touchgraph.amazoncache.io.CacheStore.generateX ML(CacheStore.java:14
at
com.touchgraph.amazoncache.io.AmazonCacheEngine.ma in(AmazonCacheEngine.java:1

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Exception of type 'System.Web.HttpUnhandledException' wasthrown.Exception has been thrown by the target of an invocation.System.WebSystem.Exception jobs ASP .Net 1 11-16-2007 05:57 PM
while executing my client program i get the exception javax.naming.LinkException: [Root exception is javax.naming.LinkException: [Root exception is javax.naming.NameNotFoundException: remaining if plz anybody know how to solve this problem then mahesh Java 0 03-08-2007 12:26 PM
can't get the text from a div, neither when I try to use innerHTML or when I try to walk the DOM Jake Barnes Javascript 2 04-07-2006 02:42 AM
Try, Try, Try, again... Rick12N4@netscape.net Computer Support 3 01-29-2005 04:02 PM
ASP XML Support - Generate XML string from FORM DATA based on XML schema Matt ASP General 3 04-23-2004 07:12 PM



Advertisments