dcsimg
Problem to serialize using XMLSerializer
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Monoranjan_Gorai
Posted On:   Wednesday, July 18, 2007 01:16 AM

Hi, I am getting exception while exucuting the following code: private void printToFile(Document dom, String filePath) { try { logger.debug("printToFile(): " + filePath); File file = new File(filePath); logger.debug(1); OutputFormat format = new OutputFormat(dom); logger.debug(2); format.setIndenting(true); // EncodingInfo encodingInfo=new EncodingInfo(); format.setEncoding("ISO-8859-1"); //format.setEncoding(encodingInfo); //format.setIndent(100); //format.setIndenting(false); logger.debug(33); // to generate a file output use fileoutputstream XMLSerializer serializer = new XMLSerializer(new FileOutpu   More>>

Hi,
I am getting exception while exucuting the following code:


private void printToFile(Document dom, String filePath) {
try {
logger.debug("printToFile(): " + filePath);
File file = new File(filePath);
logger.debug(1);
OutputFormat format = new OutputFormat(dom);
logger.debug(2);
format.setIndenting(true);
// EncodingInfo encodingInfo=new EncodingInfo();
format.setEncoding("ISO-8859-1");
//format.setEncoding(encodingInfo);
//format.setIndent(100);
//format.setIndenting(false);
logger.debug(33);
// to generate a file output use fileoutputstream
XMLSerializer serializer = new XMLSerializer(new FileOutputStream(
file), format);
logger.debug(44);
serializer.serialize(dom);
logger.debug(5);
if (format != null)
format = null;
if (serializer != null)
serializer = null;
logger.debug(6);
} catch (IOException ioException) {
logger.error(ioException, ioException);
}
}


Exception is:
java.io.IOException: The character ' ' is an invalid XML character
java.io.IOException: The character ' ' is an invalid XML character
at com.sun.org.apache.xml.internal.serialize.BaseMarkupSerializer.fatalError(BaseMarkupSerializer.java:1873)
at com.sun.org.apache.xml.internal.serialize.BaseMarkupSerializer.surrogates(BaseMarkupSerializer.java:1542)
at com.sun.org.apache.xml.internal.serialize.XMLSerializer.printText(XMLSerializer.java:1334)
at com.sun.org.apache.xml.internal.serialize.BaseMarkupSerializer.characters(BaseMarkupSerializer.java:1383)
at com.sun.org.apache.xml.internal.serialize.BaseMarkupSerializer.serializeNode(BaseMarkupSerializer.java:1059)
at com.sun.org.apache.xml.internal.serialize.XMLSerializer.serializeElement(XMLSerializer.java:1089)
at com.sun.org.apache.xml.internal.serialize.BaseMarkupSerializer.serializeNode(BaseMarkupSerializer.java:1209)
at com.sun.org.apache.xml.internal.serialize.XMLSerializer.serializeElement(XMLSerializer.java:1089)
at com.sun.org.apache.xml.internal.serialize.BaseMarkupSerializer.serializeNode(BaseMarkupSerializer.java:1209)
at com.sun.org.apache.xml.internal.serialize.XMLSerializer.serializeElement(XMLSerializer.java:1089)
at com.sun.org.apache.xml.internal.serialize.BaseMarkupSerializer.serializeNode(BaseMarkupSerializer.java:1209)
at com.sun.org.apache.xml.internal.serialize.XMLSerializer.serializeElement(XMLSerializer.java:1089)
at com.sun.org.apache.xml.internal.serialize.BaseMarkupSerializer.serializeNode(BaseMarkupSerializer.java:1209)
at com.sun.org.apache.xml.internal.serialize.XMLSerializer.serializeElement(XMLSerializer.java:1089)
at com.sun.org.apache.xml.internal.serialize.BaseMarkupSerializer.serializeNode(BaseMarkupSerializer.java:1209)
at com.sun.org.apache.xml.internal.serialize.BaseMarkupSerializer.serializeNode(BaseMarkupSerializer.java:1277)
at com.sun.org.apache.xml.internal.serialize.BaseMarkupSerializer.serialize(BaseMarkupSerializer.java:489)
at com.ezemrx.dbfactory.ExportManager.printToFile(Unknown Source)
at com.ezemrx.dbfactory.ExportManager.exportEncounterHistory(Unknown Source)
at com.ezemrx.dbfactory.ExportManager.exportHistory(Unknown Source)
at com.ezemrx.controller.ExportAction.requestToExportAll(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at uk.ltd.getahead.dwr.impl.ExecuteQuery.execute(ExecuteQuery.java:239)
at uk.ltd.getahead.dwr.impl.DefaultExecProcessor.handle(DefaultExecProcessor.java:48)
at uk.ltd.getahead.dwr.impl.DefaultProcessor.handle(DefaultProcessor.java:81)
at uk.ltd.getahead.dwr.AbstractDWRServlet.doPost(AbstractDWRServlet.java:162)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)

   <<Less
About | Sitemap | Contact