users@jaxb.java.net

RE: How does JAXB handle enumeration?

From: Robert Lowe <rmlowe_at_rmlowe.com>
Date: Sun, 15 Feb 2004 22:54:23 +0800

If the base type for the enumeration is xs:string then JAXB will not
generate type-safe enums by default. Try changing the base type to
xs:NCName.


Best regards,

Robert Lowe
http://RMLowe.com/



-----Original Message-----
From: Sam Cheung [mailto:sylcheung_at_hotmail.com]
Sent: Saturday, February 14, 2004 8:43 AM
To: users_at_jaxb.dev.java.net
Subject: Re: How does JAXB handle enumeration?



In the case I mention before, is it the very close to the one in the spec
(simple type USState on page 60).

However,

<xs:complexType name="request">
                <xs:complexContent>
                        <xs:extension base="tns:genericVASPRequestType">
                                <xs:sequence>

                                        <xs:element name="Priority" type="tns:priorityType" minOccurs="0"/>

                                </xs:sequence>
                        </xs:extension>
                </xs:complexContent>
</xs:complexType>

where priorityType is defined as a simple type.
<xs:simpleType name="priorityType">
                <xs:annotation>
                        <xs:documentation>Priority of MM</xs:documentation>
                </xs:annotation>
                <xs:restriction base="xs:string">
                        <xs:enumeration value="Normal"/>
                        <xs:enumeration value="High"/>
                        <xs:enumeration value="Low"/>
                </xs:restriction>
        </xs:simpleType>

But in the request class generated by JAXB, it only generates
setPrority(String) method. It does not generated a class called
"ProrityType" as the one shown in the example, and the parameter of
setPrority should be ProrityType instead of String.

Thanks in advance for any further help.





>From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
>Reply-To: users_at_jaxb.dev.java.net
>To: users_at_jaxb.dev.java.net
>Subject: Re: How does JAXB handle enumeration?
>Date: Fri, 13 Feb 2004 16:04:54 -0800
>
>
>We do generate the type-safe enums, but it doesn't always do so by
>default. For example, if your enumeration simple type is anonymous, it
>doesn't. But for named simple types with enumerations, you'll get
>type-safe enums.
>
>You can also use customizations to have XJC generate type-safe enums in
>cases where it does't by default. The spec might have some samples.
>
>For starter, try making that simple type a global simple type.
>
>regards,
>--
>Kohsuke Kawaguchi
>Sun Microsystems kohsuke.kawaguchi_at_sun.com
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
>For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>

_________________________________________________________________
Find great local high-speed Internet access value at the MSN High-Speed
Marketplace. http://click.atdmt.com/AVE/go/onm00200360ave/direct/01/


---------------------------------------------------------------------
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