users@jaxb.java.net

R: R: DateTime error

From: EBAStep2 <ebastep2_at_sia.it>
Date: Thu, 12 Jun 2003 10:10:28 +0200

Ed,
I've used a <javaType> customization with xjc utility, I put the following
code in my schema:

<xs:simpleType name="ISODateTime">
        <xs:annotation>
                <xs:appinfo>
                        <jxb:javaType name="java.lang.String"/>
                </xs:appinfo>
        </xs:annotation>
        <xs:restriction base="xs:dateTime"/>
</xs:simpleType>

so datetime was mapped to java.lang.String and not to java.util.Calender,
but maybe this is not enough.
Are there any other "internal mappings" between datatype that I cannot
change?
Thx,
Tito


-----Messaggio originale-----
Da: Ed Mooney [mailto:Ed.Mooney_at_Sun.COM]
Inviato: mercoled? 11 giugno 2003 20.17
A: JAXB-INTEREST_at_JAVA.SUN.COM
Oggetto: Re: R: DateTime error


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
*******************Internet Email Confidentiality Footer******************* 
Qualsiasi utilizzo non autorizzato del presente messaggio nonche' dei suoi
allegati e' vietato e potrebbe costituire reato. Se lei ha ricevuto
erroneamente il presente messaggio, Le saremmo grati se, via e-mail, ce ne
comunicasse la ricezione e provvedesse alla distruzione del messaggio stesso
e dei suoi eventuali allegati. Le dichiarazioni contenute nel presente
messaggio nonche' nei suoi eventuali allegati devono essere attribuite
esclusivamente al mittente e non possono essere considerate come trasmesse o
autorizzate da SIA S.p.A.; le medesime dichiarazioni non impegnano SIA
S.p.A. nei confronti del destinatario o di terzi. 
SIA S.p.A. non si assume alcuna responsabilita' per eventuali
intercettazioni, modifiche o danneggiamenti del presente messaggio e-mail. 
Any unauthorized use of this e-mail or any of its attachments is prohibited
and could constitute an offence. If you are not the intended addressee
please advise immediately the sender by using the reply facility in your
e-mail software and destroy the message and its attachments. The statements
and opinions expressed in this e-mail message are those of the author of the
message and do not necessarily represent those of SIA. Besides, The contents
of this message shall be understood as neither given nor endorsed by SIA
S.p.A.. 
SIA S.p.A. does not accept liability for corruption, interception or
amendment, if any, or the consequences thereof.