users@jaxb.java.net

Re: typesafe enumeration

From: Kenny MacLeod <kennym_at_kizoom.com>
Date: Tue, 15 Jul 2008 22:23:56 +0100

try using xs:NMTOKEN instead of xs:string as the base of your type. xjc
should then generate an enum type, and it won't need the appinfo to do it.

_Eric_ wrote:
> Hi list,
>
> I have a problem with enumerations. See this peace of XSD:
> <xs:element name="Sex">
> <xs:simpleType>
> <xs:annotation>
> <xs:appinfo>
> <jaxb:typesafeEnumClass name="sex">
> <jaxb:typesafeEnumMember name="MALE" value="MALE" />
> <jaxb:typesafeEnumMember name="FEMALE" value="FEMALE" />
> </jaxb:typesafeEnumClass>
> </xs:appinfo>
> </xs:annotation>
> <xs:restriction base="xs:string">
> <xs:enumeration value="MALE" />
> <xs:enumeration value="FEMALE" />
> </xs:restriction>
> </xs:simpleType>
> </xs:element>
>
> I would expect an Java-Enumeration is generated but nothing happens. The
> property of "Sex" is plain Sting :-( Does anybody see someting wrong here?
>
> The schema is included into an WSDL and I compile with Maven2 with the
> following configuration:
> <plugin>
> <groupId>org.apache.cxf</groupId>
> <artifactId>cxf-codegen-plugin</artifactId>
> <version>${cxf.version}</version>
> <executions>
> <execution>
> <id>generate-sources</id>
> <phase>generate-sources</phase>
> <goals>
> <goal>wsdl2java</goal>
> </goals>
> <configuration>
> <sourceRoot>
> ${basedir}/target/generated/src/main/java
> </sourceRoot>
> <wsdlOptions>
> <wsdlOption>
> <wsdl>${basedir}/src/main/webapp/WEB-INF/service.wsdl</wsdl>
> <extraargs>
> <extraarg>-wsdlLocation</extraarg>
> <extraarg>WEB-INF/service.wsdl</extraarg>
> </extraargs>
> </wsdlOption>
> </wsdlOptions>
> </configuration>
> </execution>
> </executions>
> </plugin>
>
> Greetings Eric
> --
> View this message in context: http://www.nabble.com/typesafe-enumeration-tp18468806p18468806.html
> Sent from the java.net - jaxb users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>