This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes Entity Resolver not working fine while unmarshalling using JAXB ? 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 "Entity Resolver not working fine while unmarshalling using JAXB ?" Watch "Entity Resolver not working fine while unmarshalling using JAXB ?" New topic
Author

Entity Resolver not working fine while unmarshalling using JAXB ?

tanu dua
Ranch Hand

Joined: Apr 05, 2004
Posts: 145
Hi ,

I am using JAXB to unmarshall XML to java using DTD . Since , DTD is on my local machine I have to use EntityResolver as follows :



The above code populates the Java objects corresponding to elements as desired but for attributes it does not bind.I have also read that there is an existing defect in JAXB that does not bind attributes with Java Objects if EntityResolver is used.

Is there any workaround please as I am stuck on that ?
[ December 04, 2008: Message edited by: tanu dua ]
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

You create the EntityResolver but don't use it, as far as I can see.

I have also read that there is an existing defect in JAXB that does not bind attributes with Java Objects if EntityResolver is used.


I don't see how JAXB would know that an EntityResolver is being used. That's transparent to users of the parser. Of course it's possible to use an EntityResolver imperfectly, but since you didn't post a link to that rumour, I can't really address it in any useful way.
tanu dua
Ranch Hand

Joined: Apr 05, 2004
Posts: 145
My Bad ! I have not attached the correct code.Here is the correct code:




I have set the entity resolver for XmlReader object and on unmarshalling all the elements are binded but attributes did not get bind.

I have seen this link while serching on teh net . The other person also having this problem , may be we both are doing something wrong or there is a defect in the Jaxb.

Jaxb Entity Resolver
A Wood
Greenhorn

Joined: Feb 24, 2009
Posts: 1
I also had trouble unmarshalling attributes when using a SAXSource. However, I eventually got it to work by using a namespace aware SAX parser:

Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Pradeep bhatt,
Your post was moved to a new topic.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Entity Resolver not working fine while unmarshalling using JAXB ?
 
Similar Threads
Set schema at runtime
How to remove carriage return and linefeeds from XML files
resolving external DTD
Stop Xerces from requesting DTD
DOM non validation parsing