• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Incorrect encoding in XML

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Marshal
Posts: 28245
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey Paul,

Thanks for your help.
Its working fine now.

Best Regards,
Aparna
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic