users@jaxb.java.net

RE: Re: unmarshalling - turn off validation to prevent unexpected elementexception

From: Gerry Plummer <GPlummer_at_teloquent.com>
Date: Mon, 15 Dec 2003 13:51:02 -0500

Hi -

I brought this issue up during the beta last winter. We have currently peppered our schema with wildcard elements but it would be extremely useful to have either a run-time property to dictate the behavior when unmarshalling encounters an unexpected element, or to at least allow a user-defined exception handler to decide that this is a recoverable error. I've forgotten the specifics, but there is as I recall a mechanism to do that, but it doesn't work for this class/level of exception.

I was also interested to learn that unexpected attributes do not produce such errors. It is only unexpected elements.

 -gerry plummer

R. Gerry Plummer
Founding Engineer
Principal Software Architect
Teloquent Communications Corporation
4 Federal St.
Billerica, MA 01821
www.teloquent.com
 
978-671-2938
gplummer_at_teloquent.com



-----Original Message-----
From: Kohsuke Kawaguchi [mailto:Kohsuke.Kawaguchi_at_Sun.COM]
Sent: Monday, December 15, 2003 1:27 PM
To: users_at_jaxb.dev.java.net
Subject: Re: unmarshalling - turn off validation to prevent unexpected elementexception



If you know where those 3rd party elements appear in your XML documents, you might want to use wildcards in the schema to describe where they can happen. This will let JAXB handle them properly.

If you can easily filter those elements out, you might consider writing a SAX XMLFilter or a simple transformation. You can use them as a pre-processing before the unmarshalling, and in this way the RI won't see any of those 3rd party elements. If you can use SAX for this, this can be done quite efficiently. If you use XSLT, this can be done quite easily.

We are also considering to make the unmarshaller more robust by recovering from unexpected elements errors.

regards,
--
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
For additional commands, e-mail: users-help_at_jaxb.dev.java.net
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
For additional commands, e-mail: users-help_at_jaxb.dev.java.net