« Return to Thread: Can JAXB Unmarshaller be configured to fail on missing xsi:type-binding?

Re: Can JAXB Unmarshaller be configured to fail on missing xsi:type-binding?

by metro-3 :: Rate this Message:

Reply to Author | View in Thread

I'm one step further although I didn't solve the problem yet.

I found out that I can use an XMLFilter to get notified of SAX events while unmarshalling. I listen to [i]startElement()[/i] and save the value of the [i]xsi:type[/i] attribute now. Additionally, I register an [i]Unmarshaller.Listener[/i] to get notified about each unmarshalled object. When [i]afterUnmarshal()[/i] is called, I have the [i]xsi:type[/i] value from the XMLFilter and the unmarshalled object's [i]getClass()[/i] value, e.g. [i]xsi:type='ns:Subtype'[/i] and [i]class org.example.Basetype[/i].

What's still missing: can JAXB tell me the XML type for the unmarshalled object somehow (which could be [i]ns:Basetype[/i] in my example)?
[Message sent by forum member 'ck1' (ck1)]

http://forums.java.net/jive/thread.jspa?messageID=355751

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...

 « Return to Thread: Can JAXB Unmarshaller be configured to fail on missing xsi:type-binding?