users@jaxb.java.net

Re: Getting a Java 5 enum from XJC

From: Kenny MacLeod <kennym_at_kizoom.com>
Date: Fri, 26 Jan 2007 09:11:25 +0000

As you say, XJC will only generated an Enum for a Schema type which has
a name, i.e. isn't an anonymous nested type. It doesn't generate enum
types for anonymous schema types - what would it call them?

Potentially, this behaviour could be over-riden, causing XJC to
auto-generate names for anonymous schema types?


Gregory Kick wrote:
> Aha! After some experimentation, I found that it just breaks if the
> simpleType is nested. If I move it outside of the complexType, give
> it it's own name and try it again, it works. Is this a bug or somehow
> justified? Let me know and i'll put into the issue tracker.
>
> On 1/25/07, Gregory Kick <gk5885_at_gmail.com> wrote:
>> Thanks for the quick reply!
>>
>> Yeah, for some reason i'm getting
>>
>> @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
>> protected String type;
>>
>> for
>>
>> <xs:complexType name="Class">
>> <xs:complexContent>
>> <xs:extension base="kse:Named">
>> <xs:sequence>
>> <xs:element name="innerClass" type="kse:Class"
>> minOccurs="0"
>> maxOccurs="unbounded"/>
>> </xs:sequence>
>> <xs:attribute name="type">
>> <xs:simpleType>
>> <xs:restriction base="xs:token">
>> <xs:enumeration value="annotation"/>
>> <xs:enumeration value="enum"/>
>> <xs:enumeration value="class"/>
>> <xs:enumeration value="interface"/>
>> <xs:enumeration value="throwable"/>
>> </xs:restriction>
>> </xs:simpleType>
>> </xs:attribute>
>> </xs:extension>
>> </xs:complexContent>
>> </xs:complexType>
>>
>> On 1/25/07, Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_sun.com> wrote:
>> >
>> > Yes, in fact that's the default behavior.
>> >
>> > I take it that you aren't seeing it though. Can you paste your schema?
>> >
>> > Gregory Kick wrote:
>> > > Is it possible to have
>> > > <xs:restriction base="xs:token">
>> > > <xs:enumeration value="whatever"/>
>> > > ...
>> > > </xs:restriction>
>> > > generate a java 5 enum?
>> > >
>> >
>> >
>> > --
>> > Kohsuke Kawaguchi
>> > Sun Microsystems kohsuke.kawaguchi_at_sun.com
>> >
>> >
>> >
>>
>>
>> --
>> Gregory Kick
>> gk5885_at_gmail.com
>>
>
>