users@jaxb.java.net

Re: Unmarshal exception..

From: Joe Fialli <joseph.fialli_at_sun.com>
Date: Thu, 07 Nov 2002 18:30:27 -0500

Bill Marcum wrote:
> I've written a schema, which cleanly compiles. If I instantiate one of these objects, use the 'set' methods to populate it, marshal it to a data stream, and then attempt to use the Unmarshaller to unmarshal it, I get an exception : javax.xml.bind.UnmarshalException: Unexpected element ....
>

After you update the java representation, one must "validate" the Java
representation to be sure that the modifications were "valid" using
javax.xml.bind.Validator.

Marshalling does not perform validation. Marshalling can work
on invalid content. It is up to the user to decide if they
wish to validate their modifications or if they want to skip
that step.

-Joe Fialli, Sun Microsystems

> I'm hoping this is because I'm doing something wrong, but it seems more likely it's a bug in JAXB, right? That is, JAXB said the schema was valid, JAXB wrote the XML, and now JAXB says the XML is invalid.


>
> Should I be pouring over the JAXB documentation trying to figure out what I did wrong, or should I be submitting a bug report?


--