users@jaxb.java.net

Re: VALIDATION MESSAGES

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Fri, 21 Mar 2003 08:00:38 -0800

> I've followed a couple of threads relating to validation messages.
> Basically the validation messages only say "length was 2 but maximum
> length is 1". It doesn't tell me what element it was, nor what the data
> was. So Is there a plan to give at least the element name and the data
> value in the future?

Oh, but those threads are about "on-demand" validation --- a kind of
validation you do on JAXB contents, not when you are unmarshalling.

When you are unmarshalling from XML, then you can access the location
information and it gives you the line number, file name, and etc. I
believe that's equivalent of what Xerces produces. Obtain
ValidationEventLocator from ValidationEvent and check out its properties.

Unfortunately the default ValidationEventHandler doesn't print the line
number, so that might be why you think we don't provide that information,
but in the next release the line number will be printed by default.


> Is this error coming because what I'm doing is not possible, or because
> I'm doing something wrong?

Hard to tell, but I suspect the latter. After all, when you pass in File,
Reader, InputStream or things like that, we internally use the
UnmarshallerHandler to unmarshal it. So it's kind of strange that it
doesn't work.

Have you turned on the namespace support on the parser (aka
setNamespaceAware(true))?

Could you post the relevant part of the source code?


regards,
--
Kohsuke KAWAGUCHI                  408-276-7063 (x17063)
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com