users@jaxb.java.net

Re: R: DateTime error

From: Ed Mooney <Ed.Mooney_at_sun.com>
Date: Wed, 11 Jun 2003 14:17:13 -0400

Hi Tito,

Sorry, I should have recognized this as a bug:

     http://developer.java.sun.com/developer/bugParade/bugs/4749458.html

 From http://java.sun.com/webservices/docs/1.1/jaxb-1.0/ReleaseNotes.html:

     The RI can fail to properly validate content trees with
     elements of date, dateTime, time. The reason is because these
     XML Schema datatypes are mapped to java.util.Calender by
     default and there are discrepancies over the timezone
     information(which is always present in the Java datatype, but
     not always in the xml datatypes)

Regards,
--
Ed Mooney         |Sun Microsystems, Inc.|Time flies like
Java Web Services |UBUR02-201            |an arrow, but
Ed.Mooney_at_Sun.COM |1 Network Drive       |fruit flies like
781-442-0459      |Burlington, MA  01803 |a banana. Groucho
EBAStep2 wrote:
> Hi,
> this is my source code :
>
>
> public static void createFvr() throws Exception, JAXBException,
> javax.xml.bind.ValidationException {
>
>         try {
>
>                 JAXBContext oj = JAXBContext.newInstance("FvrSchema");
>
>                 ObjectFactory objFactory = new ObjectFactory();
>
>                 XctFvrSTPPlusBlkCdtTrf xmlFvr =
> objFactory.createXctFvrSTPPlusBlkCdtTrf();
>
>                 PaymentInformation4 grHd =
> objFactory.createPaymentInformation4();
>                 grHd.setCreDt("2002-11-18T17:18:52");
>                 ...
>                 ...
>                 ...
>                 ...
>
>                 //Assign namespace prefix by David Megginson
>                 XMLWriter writer = new XMLWriter();
>                 writer.setPrefix("urn:XctFvr:xsd:$XctFvrSTPPlusBlkCdtTrf",
> "XctFvr");
>                 writer.setPrefix("urn:swift:xsd:$STPPlusBlkCdtTrfRjct",
> "swift");
>                 writer.forceNSDecl("urn:swift:xsd:$STPPlusBlkCdtTrfRjct");
>                 try {
>                         writer.setOutput(
>                                 new PrintWriter(
>                                         new BufferedWriter(new
> FileWriter(FvrGenerator.pathFvr + fvrFlNm))));
>                 } catch (FileNotFoundException ioe) {
>                         FvrGenerator.traceErrore = ioe.getMessage();
>                         throw ioe;
>                 }
>
>                 //Validate before marshal
>                 javax.xml.bind.Validator v = oj.createValidator();
>                 try{
>                         validateFvr = v.validate(xmlFvr);
>                 }catch (javax.xml.bind.ValidationException ve){
>                         FvrGenerator.traceErrore = ve.toString();
>                         throw ve;
>                 }
>
>                 /marshalling
>                 Marshaller m = oj.createMarshaller();
>                 m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,
> Boolean.TRUE);
>                 m.setProperty(
>                         Marshaller.JAXB_SCHEMA_LOCATION,
>                         "urn:XctFvr:xsd:$XctFvrSTPPlusBlkCdtTrf
> XctFvrSTPPlusBlkCdtTrf.xsd");
>
>                 m.marshal(xmlFvr, writer);
>
>
>         } catch (javax.xml.bind.MarshalException me) {
>                 FvrGenerator.traceErrore = me.getMessage();
>                 throw me;
>         } catch (JAXBException je) {
>                 FvrGenerator.traceErrore = je.getMessage();
>                 throw je;
>         } catch (Exception e) {
>                 //e.printStackTrace();
>                 throw e;
>         }
>
> }
>
> I get the error when I try to validate befor marshalling. In the schema the
> "CreDt" element is defined as "dateTime" datatype (timezone is not mandatory
> for this datatype).
> I'm using JAXB 1.0 beta because we cannot upgrade at this time of the
> project. I hope this does't linked to my problem, otherwise we will not make
> any validation and we just skip it...
> The XML file generated (without any validation) is good if I pass it into
> some fileprocessor (XML SPy, Tibco Turbo XML...)
> Thanks,
> Tito