You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by ja...@external.t-mobile.at on 2008/04/29 18:25:25 UTC
global jaxb binding to force to generate java enum [Virus checked]
Hello,
i have problem with several WSDLs, which are using complex types like this
.. one of element contains anonymous inner definition of restriction of
simpleType.
<complexType name='MyType'>
<sequence>
<element name='ID' type='string'/>
<element name='type'>
<simpleType>
<restriction base='int'>
<enumeration value='1'/>
<enumeration value='3'/>
<enumeration value='4'/>
<enumeration value='7'/>
<enumeration value='11'/>
</restriction>
</simpleType>
</element>
</sequence>
</complexType>
is there a possibility to define in binding (global binding or using SCD)
to always force jaxB to generate java enum for it with some name (e.g.
ComplexType name concatenated with element name)?
when i changed single definition to
<complexType
....
<element name='type'>
<simpleType>
<xsd:annotation>
<xsd:appinfo>
<jxb:typesafeEnumClass name="xx"/>
</xsd:appinfo>
</xsd:annotation>
<restriction base='int'>
....
i have an error
[INFO] Thrown by JAXB : Cannot generate a constant name from the
enumeration value "1". Use <jaxb:typesafeEnumMember name="..."/> to
specify one.
also this should be done somehow automatically .. e.g. in case of number
type, enum constants could be e.g. _X (underscore + value) and it should
take real value as constructor arg. of type int or whatever (depending on
type from xml schema)
best regards
jano
Re: Antwort: Re: global jaxb binding to force to generate java enum [Virus checked]
Posted by Adrian Corcoran <ad...@gmail.com>.
The following should work - you point at the enum you wish to customise.
However this doesn't work with a global binding - am about to file a bug
against this once I get a few test cases together.
<jaxws:bindings wsdlLocation="./test.wsdl"
xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" version="2.0">
<jaxws:bindings
node="wsdl:definitions/wsdl:types/xsd:schema[@targetNamespace='
http://www.example.org/test/']">
<jaxb:bindings node="./xsd:simpleType[@name='TestEnum']">
<jaxb:typesafeEnumClass name="TestEnum">
<jaxb:typesafeEnumMember name="SUCCESS" value="0" />
<jaxb:typesafeEnumMember name="FAILURE" value="1"
/>
</jaxb:typesafeEnumClass>
</jaxb:bindings>
</jaxws:bindings>
</jaxws:bindings>
</jaxws:bindings>
On Tue, Apr 29, 2008 at 7:38 PM, Daniel Kulp <dk...@apache.org> wrote:
>
> This is definitely a question more for the JAXB list at jaxb.java.net or
> something.
>
> That said, I would look at section 7.5.1 of the jaxb spec a bit more. If
> there is something, it would be there. Looking at it, you MIGHT be
> able to do something like:
>
> <globalBindings typesafeEnumBase="xs:string,xs:int"/>
> to allow it to create enums for "int" types. I'm by no means a jaxb
> expert so I'm not sure if that really is what is needed. You might also
> need to add typesafeEnumMemberName="generateName"
>
> Dan
>
>
>
>
> On Tuesday 29 April 2008, jan.minaroviech@external.t-mobile.at wrote:
> > i know, but i don't want to customize all wsdls .. i'm looking for
> > common global binding or extension
> > thanks.
> >
> >
> >
> >
> > "Adrian Corcoran" <ad...@gmail.com>
> > 04/29/2008 20:21
> > Bitte antworten an
> > users@cxf.apache.org
> >
> >
> > An
> > users@cxf.apache.org
> > Kopie
> >
> > Thema
> > Re: global jaxb binding to force to generate java enum [Virus checked]
> >
> >
> >
> >
> >
> >
> > you need to use
> > <jaxb:typesafeEnumMember name="XX" value="1" />
> > for the enum member
> >
> > On Tue, Apr 29, 2008 at 5:25 PM,
> > <ja...@external.t-mobile.at>
> >
> > wrote:
> > > Hello,
> > >
> > > i have problem with several WSDLs, which are using complex types
> > > like
> >
> > this
> >
> > > .. one of element contains anonymous inner definition of
> > > restriction of simpleType.
> > >
> > > <complexType name='MyType'>
> > > <sequence>
> > > <element name='ID' type='string'/>
> > > <element name='type'>
> > > <simpleType>
> > > <restriction base='int'>
> > > <enumeration value='1'/>
> > > <enumeration value='3'/>
> > > <enumeration value='4'/>
> > > <enumeration value='7'/>
> > > <enumeration value='11'/>
> > > </restriction>
> > > </simpleType>
> > > </element>
> > > </sequence>
> > > </complexType>
> > >
> > >
> > > is there a possibility to define in binding (global binding or using
> >
> > SCD)
> >
> > > to always force jaxB to generate java enum for it with some name
> > > (e.g. ComplexType name concatenated with element name)?
> > >
> > > when i changed single definition to
> > > <complexType
> > > ....
> > > <element name='type'>
> > > <simpleType>
> > > <xsd:annotation>
> > > <xsd:appinfo>
> > > <jxb:typesafeEnumClass name="xx"/>
> > > </xsd:appinfo>
> > > </xsd:annotation>
> > > <restriction base='int'>
> > > ....
> > > i have an error
> > > [INFO] Thrown by JAXB : Cannot generate a constant name from the
> > > enumeration value "1". Use <jaxb:typesafeEnumMember name="..."/> to
> > > specify one.
> > >
> > > also this should be done somehow automatically .. e.g. in case of
> > > number type, enum constants could be e.g. _X (underscore + value)
> > > and it should take real value as constructor arg. of type int or
> > > whatever (depending
> >
> > on
> >
> > > type from xml schema)
> > >
> > >
> > >
> > > best regards
> > > jano
>
>
>
> --
> J. Daniel Kulp
> Principal Engineer, IONA
> dkulp@apache.org
> http://www.dankulp.com/blog
>
Re: Antwort: Re: global jaxb binding to force to generate java enum [Virus checked]
Posted by Daniel Kulp <dk...@apache.org>.
This is definitely a question more for the JAXB list at jaxb.java.net or
something.
That said, I would look at section 7.5.1 of the jaxb spec a bit more. If
there is something, it would be there. Looking at it, you MIGHT be
able to do something like:
<globalBindings typesafeEnumBase="xs:string,xs:int"/>
to allow it to create enums for "int" types. I'm by no means a jaxb
expert so I'm not sure if that really is what is needed. You might also
need to add typesafeEnumMemberName="generateName"
Dan
On Tuesday 29 April 2008, jan.minaroviech@external.t-mobile.at wrote:
> i know, but i don't want to customize all wsdls .. i'm looking for
> common global binding or extension
> thanks.
>
>
>
>
> "Adrian Corcoran" <ad...@gmail.com>
> 04/29/2008 20:21
> Bitte antworten an
> users@cxf.apache.org
>
>
> An
> users@cxf.apache.org
> Kopie
>
> Thema
> Re: global jaxb binding to force to generate java enum [Virus checked]
>
>
>
>
>
>
> you need to use
> <jaxb:typesafeEnumMember name="XX" value="1" />
> for the enum member
>
> On Tue, Apr 29, 2008 at 5:25 PM,
> <ja...@external.t-mobile.at>
>
> wrote:
> > Hello,
> >
> > i have problem with several WSDLs, which are using complex types
> > like
>
> this
>
> > .. one of element contains anonymous inner definition of
> > restriction of simpleType.
> >
> > <complexType name='MyType'>
> > <sequence>
> > <element name='ID' type='string'/>
> > <element name='type'>
> > <simpleType>
> > <restriction base='int'>
> > <enumeration value='1'/>
> > <enumeration value='3'/>
> > <enumeration value='4'/>
> > <enumeration value='7'/>
> > <enumeration value='11'/>
> > </restriction>
> > </simpleType>
> > </element>
> > </sequence>
> > </complexType>
> >
> >
> > is there a possibility to define in binding (global binding or using
>
> SCD)
>
> > to always force jaxB to generate java enum for it with some name
> > (e.g. ComplexType name concatenated with element name)?
> >
> > when i changed single definition to
> > <complexType
> > ....
> > <element name='type'>
> > <simpleType>
> > <xsd:annotation>
> > <xsd:appinfo>
> > <jxb:typesafeEnumClass name="xx"/>
> > </xsd:appinfo>
> > </xsd:annotation>
> > <restriction base='int'>
> > ....
> > i have an error
> > [INFO] Thrown by JAXB : Cannot generate a constant name from the
> > enumeration value "1". Use <jaxb:typesafeEnumMember name="..."/> to
> > specify one.
> >
> > also this should be done somehow automatically .. e.g. in case of
> > number type, enum constants could be e.g. _X (underscore + value)
> > and it should take real value as constructor arg. of type int or
> > whatever (depending
>
> on
>
> > type from xml schema)
> >
> >
> >
> > best regards
> > jano
--
J. Daniel Kulp
Principal Engineer, IONA
dkulp@apache.org
http://www.dankulp.com/blog
Antwort: Re: global jaxb binding to force to generate java enum [Virus
checked]
Posted by ja...@external.t-mobile.at.
i know, but i don't want to customize all wsdls .. i'm looking for common
global binding or extension
thanks.
"Adrian Corcoran" <ad...@gmail.com>
04/29/2008 20:21
Bitte antworten an
users@cxf.apache.org
An
users@cxf.apache.org
Kopie
Thema
Re: global jaxb binding to force to generate java enum [Virus checked]
you need to use
<jaxb:typesafeEnumMember name="XX" value="1" />
for the enum member
On Tue, Apr 29, 2008 at 5:25 PM, <ja...@external.t-mobile.at>
wrote:
> Hello,
>
> i have problem with several WSDLs, which are using complex types like
this
> .. one of element contains anonymous inner definition of restriction of
> simpleType.
>
> <complexType name='MyType'>
> <sequence>
> <element name='ID' type='string'/>
> <element name='type'>
> <simpleType>
> <restriction base='int'>
> <enumeration value='1'/>
> <enumeration value='3'/>
> <enumeration value='4'/>
> <enumeration value='7'/>
> <enumeration value='11'/>
> </restriction>
> </simpleType>
> </element>
> </sequence>
> </complexType>
>
>
> is there a possibility to define in binding (global binding or using
SCD)
> to always force jaxB to generate java enum for it with some name (e.g.
> ComplexType name concatenated with element name)?
>
> when i changed single definition to
> <complexType
> ....
> <element name='type'>
> <simpleType>
> <xsd:annotation>
> <xsd:appinfo>
> <jxb:typesafeEnumClass name="xx"/>
> </xsd:appinfo>
> </xsd:annotation>
> <restriction base='int'>
> ....
> i have an error
> [INFO] Thrown by JAXB : Cannot generate a constant name from the
> enumeration value "1". Use <jaxb:typesafeEnumMember name="..."/> to
> specify one.
>
> also this should be done somehow automatically .. e.g. in case of number
> type, enum constants could be e.g. _X (underscore + value) and it should
> take real value as constructor arg. of type int or whatever (depending
on
> type from xml schema)
>
>
>
> best regards
> jano
Re: global jaxb binding to force to generate java enum [Virus checked]
Posted by Adrian Corcoran <ad...@gmail.com>.
you need to use
<jaxb:typesafeEnumMember name="XX" value="1" />
for the enum member
On Tue, Apr 29, 2008 at 5:25 PM, <ja...@external.t-mobile.at>
wrote:
> Hello,
>
> i have problem with several WSDLs, which are using complex types like this
> .. one of element contains anonymous inner definition of restriction of
> simpleType.
>
> <complexType name='MyType'>
> <sequence>
> <element name='ID' type='string'/>
> <element name='type'>
> <simpleType>
> <restriction base='int'>
> <enumeration value='1'/>
> <enumeration value='3'/>
> <enumeration value='4'/>
> <enumeration value='7'/>
> <enumeration value='11'/>
> </restriction>
> </simpleType>
> </element>
> </sequence>
> </complexType>
>
>
> is there a possibility to define in binding (global binding or using SCD)
> to always force jaxB to generate java enum for it with some name (e.g.
> ComplexType name concatenated with element name)?
>
> when i changed single definition to
> <complexType
> ....
> <element name='type'>
> <simpleType>
> <xsd:annotation>
> <xsd:appinfo>
> <jxb:typesafeEnumClass name="xx"/>
> </xsd:appinfo>
> </xsd:annotation>
> <restriction base='int'>
> ....
> i have an error
> [INFO] Thrown by JAXB : Cannot generate a constant name from the
> enumeration value "1". Use <jaxb:typesafeEnumMember name="..."/> to
> specify one.
>
> also this should be done somehow automatically .. e.g. in case of number
> type, enum constants could be e.g. _X (underscore + value) and it should
> take real value as constructor arg. of type int or whatever (depending on
> type from xml schema)
>
>
>
> best regards
> jano