Anything wrong with the approach I am taking that makes it not catch the
error ?
Is it okay to catch a validation error event and ignore ? e.g. date is
invalid in XML Schema format... but valid with my conversion methods...
Since I know it will work with my method (or throw a parse exception, if not
valid), I ignore the XML schema validation event...
Thanks
-----Original Message-----
From: Sriram Thyagarajan
Sent: Monday, May 05, 2003 12:28 PM
To: 'JAXB-INTEREST_at_JAVA.SUN.COM'
Subject: RE: Does not throw an validation exception
Her is the convertor code
public static java.util.Calendar parseDateToCalendar_yyyyMMdd(String
inDate)
throws ParseException {
Calendar cal1 = DatatypeConverter.parseDate("");
if (inDate == null || inDate.equals("")) {
return null;
}
inDate = inDate.trim();
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
sdf.setLenient(false);
Date dt = sdf.parse(inDate);
Calendar cal = Calendar.getInstance();
cal.setTime(dt);
return cal;
}
public static String parseCalendarToDate_yyyyMMdd(Calendar inCalendar) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
sdf.setLenient(false);
Date dt = inCalendar.getTime();
String outDate = sdf.format(dt);
return outDate;
}
-----Original Message-----
From: Kohsuke Kawaguchi [mailto:Kohsuke.Kawaguchi_at_Sun.COM]
Sent: Monday, May 05, 2003 12:09 PM
To: JAXB-INTEREST_at_JAVA.SUN.COM
Subject: Re: Does not throw an validation exception
I tried to compile the schema but it didn't work because I don't have
XMLDataConvertor you are using.
But now I see what the problem is. Your date "20010501" is not a valid
value for xs:date. So the validator flags an error at this point. (Now
there could be a bug for it to fail to report that problem, but I can't
really test it unless I have your custom datatype converter)
Once a validator finds an error, it goes into the panic mode, so that it
won't report any false error messages. This makes it skip the next
problem, since those two errors are so nearby and the validator thinks
those are a part of the same errors.
regards,
--
Kohsuke KAWAGUCHI 408-276-7063 (x17063)
Sun Microsystems kohsuke.kawaguchi_at_sun.com