Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

jaxb unmarshalling: how to ignore unknown elements?

843834Dec 4 2006 — edited Dec 15 2006
Hi,
I use jaxb 1.1 for communication with an external partner. (Took schema, compiled it, used generated classes for unmarshalling like this:
Document doc = /* some document building */
JAXBContext jaxbContext = JAXBContext.newInstance(MyConstants.JAXB_PACKAGE);
Unmarshaller unMarshaller = jaxbContext.createUnmarshaller();
myObject = (MyObject) unMarshaller.unmarshal(doc);
) Everything worked fine until they decided to add new elements to their xml-Document without notifiing me (nothing very unusual I think...). Now I get a javax.xml.bind.UnmarshallingException with Message "Unexpected Element". Is there any way to ignore such elements and just take the known Elements from the xml-stream?

Thanks in advance

Thomas
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 12 2007
Added on Dec 4 2006
1 comment
5,409 views