Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
R Ramesh
Greenhorn
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" >
<ReturnCode>X</ReturnCode>
<Errorcode>X23</Fehlercode>
<ErrorMsg>Inhalt des Feldes ung�ltig</ErrorMsg>
</Error>
----------------------------------------------------------------------------------------------

Many Thanks in advance
 
Paul Clapham
Sheriff
Posts: 21152
32
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
Greenhorn
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic