users@jaxb.java.net

Re: Does not throw an validation exception

From: Sriram Thyagarajan <Sriram_Thyagarajan_at_KEANE-NNE.com>
Date: Mon, 05 May 2003 12:27:33 -0400

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