users@jaxb.java.net

Re: Edit Schema type on input parameter

From: Wolfgang Laun <wolfgang.laun_at_gmail.com>
Date: Wed, 30 Nov 2011 12:04:14 +0100

You mean that JAXB's schemagen creates some XML schema from this or similar?
   public void doSomething( @XmlElement String data ){...}

-W

On 29 November 2011 21:52, Jeremy Robertson <jeremychocolate_at_gmail.com>wrote:

> No, it isn't. It's a SOAP Service method. When it runs through the JaxB
> translation, the parameter is interpreted to be a xs:dateTime. I want it to
> be a xs:date type parameter.
>
> With JaxB 2.2, XmlElement and a few other annotations are now allowed on
> parameters. Allowing XmlSchemaType on parameters seems like the natural fit
> for this kind of scenario, but if that's not allowed, is there any other
> way to get the customization I need?
>
> Thanks,
> Jeremy
>
> On Tue, Nov 29, 2011 at 11:53 AM, Wolfgang Laun <wolfgang.laun_at_gmail.com>wrote:
>
>> Setter arguments are of the property type.
>>
>> If doSomething() isn't a setter you hold bad cards.
>>
>> -W
>>
>>
>> On 29 November 2011 19:43, Jeremy Robertson <jeremychocolate_at_gmail.com>
>> wrote:
>> > The problem is that the snippet below shows day as a field or property.
>> I
>> > need it to be an input parameter:
>> > protected doSomething(@XmlSchemaType(name="date") Date day);
>> >
>> > Jeremy
>> >
>> > On Tue, Nov 29, 2011 at 10:43 AM, Wolfgang Laun <
>> wolfgang.laun_at_gmail.com>
>> > wrote:
>> >>
>> >> Going from the XML schema entry
>> >>
>> >> <xs:element name="Day" type="xs:date"/>
>> >>
>> >> and by calling xjc you get Java code with annotations
>> >>
>> >> @XmlElement(name = "Day", required = true)
>> >> @XmlSchemaType(name = "date")
>> >> protected XMLGregorianCalendar day;
>> >>
>> >> and the usual getter and setter. I'd expect that a schemagen from this
>> >> should give you what you want, but I haven't tried it.
>> >>
>> >> HTH
>> >> -W
>> >>
>> >>
>> >> On 29 November 2011 17:21, <jeremychocolate_at_gmail.com> wrote:
>> >> > I am working on a web service using CXF/JAXB. I am trying to modify
>> the
>> >> > generated XML schema for a date parameter.
>> >> >
>> >> > Given the following method signature:
>> >> > public void Something(Date theDate);
>> >> >
>> >> > How can I modify theDate such that it’s schema is xs:date rather than
>> >> > xs:dateTime?
>> >> >
>> >> > What I would like to do:
>> >> > public void Something(@XmlSchemaType(name=”date”)Date theDate);
>> >> >
>> >> > I have endorsed jaxb-api v2.2.1, which has allowed me to add the
>> >> > XmlElement annotation, on theDate, but I really need the
>> XmlSchemaType
>> >> > annotation (or is there a way to use the type attribute of
>> XmlElement?)
>> >> >
>> >> >
>> >> > Thanks,
>> >> > Jeremy Robertson
>> >
>> >
>>
>
>