Thank you for the quick response. Just to make sure I understand what
you are saying, all unions will be treated as a string and I would use
something like this:
myObject.setMyField(mySqlDate.toString());
mySqlDate.valueOf(myObject.getMyField());
Would I be using JAXB verification now to determine if the input/output
matches my schema for union, restrictions, etc?
Scott Allan
Integrated Benefit Solutions, Inc.
Work: (205) 439-4521
Email: scott_at_ibs2.com
EFax: (928) 832-1509
AIM: ibsscott
Yahoo IM: ibsscott
-----Original Message-----
From: Joe Fialli [mailto:Joseph.Fialli_at_Sun.COM]
Sent: Tuesday, July 19, 2005 12:46 PM
To: users_at_jaxb.dev.java.net
Subject: Re: JAXB 2.0 union
Scott Allan wrote:
> I'm testing out the early access JAXB 2.0. I have this datatype
> defined in my schema which currently works in 1.0 but I am getting a
> different result in 2.0. I would expect that if a have an element
> assigned to this "dateType" that I could put in either java sql.Date
> value or a java.lang.String value such as:
>
Handling for union has changed between JAXB 1.0 and JAXB 2.0.
From ChangeLog in JAXB 2.0 Early Draft 2:
XSD to Java Binding
Simplified following bindings:
- union by binding to String rather than Object.
Rationale for change is that it is quite complex computation to take an
XML data value and compute
which union membertype it matches and then convert that string to that
data type. JAXB 1.0
generated specialized code to do this for each union. A goal in JAXB
2.0 was to reduce
the large amounts of generated specialized code. While there is an
observable reduction in functionality,
it was judged that the benefits of lower complexity in generated code
and faster unmarshal/marshal times when
the data was not even accessed were worth the change.
-Joe Fialli, Sun Microsystems
> myObject.setMyField(mySqlDate);
>
> I'm getting this error
> Error(196): setMyField(java.lang.String) in myPackage.TestType cannot
> be applied to (java.sql.Date)
>
> <xs:simpleType name="dateType">
> <xs:union>
> <xs:simpleType>
> <xs:annotation>
> <xs:appinfo>
> <jaxb:javaType name="java.sql.Date"
> parseMethod="valueOf"
> printMethod="toString"/>
> <!-- sample format 2003-10-13 -->
> </xs:appinfo>
> </xs:annotation>
> <xs:restriction base="xs:date"/>
> </xs:simpleType>
> <xs:simpleType>
> <xs:restriction base="xs:string">
> </xs:restriction>
> </xs:simpleType>
> </xs:union>
> </xs:simpleType>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
For additional commands, e-mail: users-help_at_jaxb.dev.java.net
_____
<< ella for Spam Control >> has removed 23543 Spam messages and set
aside 2 Newsletters for me
You can use it too - and it's FREE! www.ellaforspam.com