Are we talking about a Sun internal "1.0 FCS"? The beta is still here:
http://java.sun.com/xml/jaxb/
Gary
-----Original Message-----
From: Ryan Shoemaker - JavaSoft East [mailto:Ryan.Shoemaker_at_Sun.COM]
Sent: Tuesday, February 11, 2003 9:28 AM
To: JAXB-INTEREST_at_JAVA.SUN.COM
Subject: Re: typesafe enum error
R Bagge wrote:
> The typesafe enum shown in SampleApp6 works.
> However, if the typesafe enum USState is used in another element, the
> result in the USState.java file contains multiple declarations of the
> same object, e.g.
>
> So, is this me or JAXB? Other than that, I have found JAXB to solve
> all my needs.
>
This must be a bug in the beta release. I just ran it against the 1.0
FCS release candidate and it generated the correct typesafe enum (although
slightly different than what the beta compiler generates):
public final static java.lang.String _AK =
com.sun.xml.bind.WhiteSpaceProcessor.collapse("AK");
public final static primer.myPo.USState AK = new
primer.myPo.USState(_AK);
public final static java.lang.String _AL =
com.sun.xml.bind.WhiteSpaceProcessor.collapse("AL");
public final static primer.myPo.USState AL = new
primer.myPo.USState(_AL);
public final static java.lang.String _AR =
com.sun.xml.bind.WhiteSpaceProcessor.collapse("AR");
public final static primer.myPo.USState AR = new
primer.myPo.USState(_AR);
public final static java.lang.String _CA =
com.sun.xml.bind.WhiteSpaceProcessor.collapse("CA");
public final static primer.myPo.USState CA = new
primer.myPo.USState(_CA);
public final static java.lang.String _MA =
com.sun.xml.bind.WhiteSpaceProcessor.collapse("MA");
public final static primer.myPo.USState MA = new
primer.myPo.USState(_MA);
[...etc...]
Thanks for the report...
--Ryan Shoemaker, Sun Microsystems, Inc.
> RB
>
> The generated USState.java file:
>
> public final static primer.myPo.USState AK = new primer.myPo.USState
> ("AK");
> private final static Object $$$_AK =
> com.sun.xml.bind.WhiteSpaceProcessor.collapse("AK");
> public final static primer.myPo.USState AL = new primer.myPo.USState
> ("AL");
> private final static Object $$$_AL =
> com.sun.xml.bind.WhiteSpaceProcessor.collapse("AL");
> public final static primer.myPo.USState AK = new primer.myPo.USState
> ("AK");
> ...
> // Then it repeats again!
> private final static Object $$$_AK =
> com.sun.xml.bind.WhiteSpaceProcessor.collapse("AK");
> public final static primer.myPo.USState AL = new primer.myPo.USState
> ("AL");
> private final static Object $$$_AL =
> com.sun.xml.bind.WhiteSpaceProcessor.collapse("AL");
> ...
>
>
> The following is the enclosed XSD file:
>
> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
> jxb:version="1.0">
> <xsd:annotation>
> <xsd:appinfo>
> <jxb:globalBindings
> fixedAttributeAsConstantProperty="false"
> collectionType="java.util.Vector"
>
> typesafeEnumBase="xsd:NMToken"
> typesafeEnumMemberName="generateName"
>
> choiceContentProperty="false"
> modelGroupAsClass="false"
> enableFailFastCheck="false"
> generateIsSetMethod="false"
> underscoreBinding="asCharInWord"/>
> <jxb:schemaBindings>
> <jxb:package name="primer.myPo"/>
> <jxb:nameXmlTransform>
> <jxb:elementName suffix="Element"/>
> </jxb:nameXmlTransform>
> </jxb:schemaBindings>
> </xsd:appinfo>
> </xsd:annotation>
>
> <xsd:element name="purchaseOrder">
> <xsd:complexType >
> <xsd:sequence>
> <xsd:element name="shipTo" type="USState"/>
> <!-- adding billTo results in bad compilation of USState.java -->
> <xsd:element name="billTo" type="USState"/>
> </xsd:sequence>
> <xsd:attribute name="myState" type="USState" />
> </xsd:complexType>
> </xsd:element>
>
> <xsd:simpleType name="USState">
> <xsd:annotation>
> <xsd:appinfo>
> <jxb:typesafeEnumClass/>
> </xsd:appinfo>
> <xsd:documentation>
> This is a localized way to map this simple type definition
> to a typesafe enum class. See jxb:globalBindings
> @typesafeEnumBase above for a global way to accomplish this
> for all simple type definitions similar to this one.
> </xsd:documentation>
> </xsd:annotation>
> <xsd:restriction base="xsd:NMTOKEN">
> <xsd:enumeration value="AK"/>
> <xsd:enumeration value="AL"/>
> <xsd:enumeration value="AR"/>
> <xsd:enumeration value="CA"/>
> <xsd:enumeration value="MA"/>
> </xsd:restriction>
> </xsd:simpleType>
> </xsd:schema>
>