This week's book giveaway is in the General Computing forum.
We're giving away four copies of Emmy in the Key of Code and have Aimee Lucido on-line!
See this thread for details.
Win a copy of Emmy in the Key of Code this week in the General Computing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

Incorrect encoding in XML

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I need to convert a xml file to a HTML file. The encoding is not mentioned in the XML, so default it takes is UTF-8. I used XSL for converting XML to HTML. Below is the code sample


The problem is if the XML file contains any double byes characters like ¿? it throws exception
ERROR: 'com.sun.org.apache.xml.internal.utils.WrappedRuntimeException: Invalid byte 1 of 1-byte UTF-8 sequence.'
If I mention encoding="iso-8859-1" in XML prolog, then it works fine
Is there any way to parse the XML file with doube byte characters without modifying input XML file?
Any help is really appriciated.

Thanks in advance!
 
Sheriff
Posts: 24654
58
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So... the XML document doesn't declare its encoding correctly. You should tell the people who created that XML document, so they can fix up their process.

But yes, you can work around their faulty document by simply passing a Reader with the correct encoding to the parser:

 
Aparna Soniminde
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Paul,

Thanks for your help.
Its working fine now.

Best Regards,
Aparna
 
No matter how many women are assigned to the project, a pregnancy takes nine months. Much longer than this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!