http://weblogs.java.net/blog/felipegaucho/archive/2009/12/06/jaxb-customization-xsddatetime
On Tue, Jan 12, 2010 at 7:16 PM, KARR, DAVID (ATTCINW) <dk068x_at_att.com> wrote:
>> -----Original Message-----
>> From: Wolfgang Laun [mailto:wolfgang.laun_at_gmail.com]
>> Sent: Tuesday, January 12, 2010 10:13 AM
>> To: users_at_jaxb.dev.java.net
>> Subject: Re: Would a XMLGregorianCalendar field marshal as a "datetime"
>> value if not qualified with @XMLSchemaType(name="date")?
>>
>> Perhaps you need not worry.
>>
>> To construct your element of type DateWithoutTimezoneInfo according to
>> the generated Java code, from, e.g.,
>>
>> <xs:complexType name="DocType">
>> <xs:sequence>
>> <xs:element name="dntz" type="DateWithoutTimezoneInfo"/>
>> </xs:sequence>
>> </xs:complexType>
>>
>> you write Java code such as
>>
>> DatatypeFactory dtf = DatatypeFactory.newInstance();
>> XMLGregorianCalendar date = dtf.newXMLGregorianCalendar();
>> date.setYear( 2010 );
>> date.setMonth( 1 );
>> date.setDay( 12 );
>> doc.setDntz( date );
>>
>> and this marshals to
>>
>> <doc>
>> <dntz>2010-01-12</dntz>
>> </doc>
>>
>> which is indeed "just a date".
>
> Yes, I've already implemented a similar workaround, but I would assume that if xjc found an element of type "xs:date", it would have generated a field with a @XmlSchemaType(name = "date") annotation. Isn't that true?
>
>> On Tue, Jan 12, 2010 at 5:09 PM, KARR, DAVID (ATTCINW) <dk068x_at_att.com>
>> wrote:
>> >
>> > I meant to describe a simple type with a xs:date restriction, like
>> this:
>> >
>> > --------------------------
>> >
>> > <xs:simpleType name='DateWithoutTimezoneInfo'>
>> >
>> > <xs:annotation>
>> >
>> > <xs:documentation>Designates a date with no timezone
>> information. The following formats is accepted: YYYY-MM-DD
>> >
>> > Where
>> :
>> >
>> > -
>> YYYY indicates the year
>> >
>> > - MM
>> indicates the month
>> >
>> > - DD
>> indicates the day</xs:documentation>
>> >
>> > </xs:annotation>
>> >
>> > <xs:restriction base='xs:date'/>
>> >
>> > </xs:simpleType>
>> >
>> > --------------------------
>> >
>> >
>> >
>> >
>> >
>> > From: Wolfgang Laun [mailto:wolfgang.laun_at_gmail.com]
>> > Sent: Tuesday, January 12, 2010 7:43 AM
>> > To: users_at_jaxb.dev.java.net
>> > Subject: Re: Would a XMLGregorianCalendar field marshal as a
>> "datetime" value if not qualified with @XMLSchemaType(name="date")?
>> >
>> >
>> >
>> > On Tue, Jan 12, 2010 at 1:29 AM, KARR, DAVID (ATTCINW)
>> <dk068x_at_att.com> wrote:
>> >
>> > To provide a little more background on this, I think I might be
>> seeing a
>> > jaxb buglet that created the situation I'm in, but I need to try some
>> > more experiments. I had an element in a schema that is of type
>> > "xs:date", but it was wrapped by a local type with an xs:date
>> > restriction.
>> >
>> > Could you please provide the schema code for this "local type"? I
>> can't imagine
>> > what you are describing. xs:date is a simple type, so how can it be a
>> "wrapper"
>> > for another XML element?
>> >
>> > -W
>> >
>> >
>> > The resulting generated code didn't add the
>> > "@XmlSchemaType(name="date")" annotation, which I think it should
>> have.
>> > To work around this, would we be able to add a "<xs:annotation>
>> > <xs:appinfo>" block to the wrapper type to make it somehow generate
>> with
>> > the "@XmlSchemaType..." annotation? What would that look like?
>> >
>> > > -----Original Message-----
>> > > From: KARR, DAVID (ATTCINW)
>> > > Sent: Monday, January 11, 2010 4:07 PM
>> > > To: users_at_jaxb.dev.java.net
>> > > Subject: Would a XMLGregorianCalendar field marshal as a "datetime"
>> > > value if not qualified with @XMLSchemaType(name="date")?
>> > >
>> > > If I have a XMLGregorianCalendar field, and I do NOT have a
>> > > @XMLSchemaType(name="date") annotation on it, will it render as a
>> > > "datetime" value? That's essentially what I'm seeing. I need to
>> make
>> > > it render as just a date. Is it possible to configure JAXB to do
>> this
>> > > without changing the schema or the generated classes?
>> > >
>> > > -------------------------------------------------------------------
>> --
>> > > To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
>> > > For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>> >
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
>> > For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>> >
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
>> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>
>
--
------------------------------------------
Felipe Gaúcho
10+ Java Programmer
CEJUG Senior Advisor