users@jaxb.java.net

Re: Programmatic validation

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Mon, 29 Nov 2004 09:16:28 -0800

w5cdc-devjavanet_at_yahoo.ca wrote:
> Is there any way to have JAXB incorporate programmatic
> validation into the generated class when a document is
> unmarshalled/validated.
>
> I have the structure
>
> <date><starttime></starttime><endtime></endtime></date>.
>
>
> I would like to ensure that <endtime> is greater than
> <starttime>.
>
> Possible?

I guess one way is to use the <jaxb:class implClass> customization to
have the JAXB RI use your derived class, where you override methods and
perform extra check.

Unfortunately. we haven't designed a good hook, so it's not easy to do
what you are trying to do. For validation, I guess you can override the
createRawValidator method and then perform the check there, but this
isn't a place designed for it, so you can't even report an error to
ValidationEventHandler.

In 2.0, I think we can design hooks so you can do these things easily.


-- 
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