• 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 ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Why the html symbols & umlauts are not converted during unmarshalling in JAXB1.6?

Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Iam using JAXB1.6 to convert the below xml to java object.
After unmarshalling when I print the contents for ErrorMsg element, JAXB doesn't do any conversion for & and the character mentioned in ENTITY in the xml. It just prints as such what is in the xml. Where as i need the output as like " Inhalt des Feldes ung� >ig "

Could you please tell that do I need set any property while unmarshalling or do I need to specify any option in xjc compiler while creating JAXB classes?

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE Umschlag[><!ENTITY auml "ä"><!ENTITY ouml "ö"><!ENTITY uuml "ü"><!ENTITY Auml "Ä"><!ENTITY Ouml "Ö"><!ENTITY Uuml "Ü"><!ENTITY szlig "ß">]>
<Error version="1.0" >
<ErrorMsg>Inhalt des Feldes ung�ltig</ErrorMsg>

Many Thanks in advance
Posts: 24594
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Would it be correct to say that the actual data in your XML document looks like this?I can't guess what you meant you needed the "output" to look like, but maybe you could clarify that, and why you need it to look like that. For background information about your question, the entities you have in that document describe to the parser how it should decipher certain pieces of text (such as &uuml;). There is nothing that requires users of that document to keep track of where those entities were used, or to use the entities again when serializing from internal form to XML.

In other words, when a parser converts that XML document to internal form, it will convert the entity &uuml; to the character ü. It may tell the program that called the parser that it did an entity conversion, but that's all. It is not permitted to leave the entity unchanged in the text, because that would amount to changing the text.
R Ramesh
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks paul for your perfect explanation. I get confused while posting this query. Yes, you are right, parser does the character conversion by reading the characters in entity element against the value in the xml element.

Thank you very much for your help.
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!