*
The moose likes XML and Related Technologies and the fly likes The character '' is an invalid XML character exception getting while export data in XML file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "The character Watch "The character New topic
Author

The character '' is an invalid XML character exception getting while export data in XML file

sumanta panda
Ranch Hand

Joined: Jun 23, 2008
Posts: 224
Dear All,

I am extract data from database and export in XML file.

If in the database table contains less than 8000 records then the xml generated successfully.

But if the record contains more than 8000 records while export data in xml file it is throwing the exception

ERROR [main] - Error in xmlExport
java.io.IOException: The character '' is an invalid XML character
at org.apache.xml.serialize.BaseMarkupSerializer.characters(Unknown Source)
at com.siemens.plmwbs.dao.ExportPlmWbsDao.generateXMLFile(ExportPlmWbsDao.java:137)
at com.siemens.plmwbs.dao.ExportPlmWbsDao.getFileData(ExportPlmWbsDao.java:252)
at com.siemens.plmwbs.exportwbs.PLMWbsExporter.generatePLMWBSXMLFile(PLMWbsExporter.java:100)
at com.siemens.plmwbs.exportwbs.PLMWbsExporter.main(PLMWbsExporter.java:67)



Below given the code:-



Please suggest how to fix this error.

Thanks in advance.

Regards,
Sumanta Panda
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12761
    
    5
You will have to find out the true identity of the illegal character and then figure out what is generating it.

The square you are seeing is just the operating system's attempt to show a character it doesnt have a font for.

If this was my problem I would catch the IO exception and dump the message as hex bytes. Hopefully the identity of the character will give you a clue as to where it comes from.

Try the toCharArray method to get the message characters and the Integer.toHexString( int ) method to get the hex representation.

What is the original source of the Strings in the database? If it is Word documents then "smart punctuation" may be your problem.

Bill
sumanta panda
Ranch Hand

Joined: Jun 23, 2008
Posts: 224
Dear William Brogden,

Thanks William Brogden for your response.The character ''is an invalid XML character exception issue has been solved.This issue happened because of''the table record.When i remove'' this record from table.It is working.

One more issue i am facing.

My table contains 82704 correct records.I didnt get any error/exception while export in xml file.

While export, few records is export in the xml file .But from the end few records is not exported.

While open the generated xml file in the end the error message is showing

"THE XML PAGE CANNOT BE DISPLAYED"
NOT ENOUGH STORAGE IS AVAILABLE TO COMPLETE THIS OPEARTION"


Please note that the location of the xml file contains enough space.

But how many maximum record we export in the xml file at a time.

The generated xml file size is 44.1 mb.

Please suggest how i resolve this issue.

Thanks for the understaning.

Regards,
Sumanta Panda
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12761
    
    5
While open the generated xml file in the end the error message is showing


What program are you using to try to display this XML document?

While the text may take 44.1mb, if the program needs to create a DOM before displaying it, MUCH more memory will be needed. This because a DOM creates a new object for every data element in the document.

Bill
sumanta panda
Ranch Hand

Joined: Jun 23, 2008
Posts: 224
Dear William,

Thanks for your response.Sir i am begineer for writting xml program.
Could you please identity my mistake in the above given code and also suggest me what the piece of code i need to change so that it should work.

Thanks and Regards,
Sumanta Panda

Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

The code you posted produces an XML file correctly, right? But then some other code fails to display that XML file because it's too large? Do I understand that correctly?

If that's the case, then the code you posted is correct code. The problem is with that other code which can't display a very large XML document. Although I wouldn't really be very concerned about that; there aren't any users who will want to display such a large document and look through it.
 
Don't get me started about those stupid light bulbs.
 
subject: The character '' is an invalid XML character exception getting while export data in XML file
 
Similar Threads
org.apache.xml.serialize - problem in linux
Sending XML to a mobile phone
org.apache.xml.serialize problem in linux
How to read and write the data in XML file
Data is not properly export in the XML file