You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by "Shaw, Richard A" <ri...@atkinsglobal.com> on 2008/04/03 15:01:19 UTC
JAXB substitutionGroups
Does anybody know why XSD substitutionGroups cause JAXB to create code like the following -
List<JAXBElement<? Extends AbstractFeatureType> > features;
Why isn't it simply -
List<AbstractFeatureType> features;
Is there any way to change it ? I searched the web and couldn't find anything.
Richard Shaw
¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø¤º°`°º¤ø,¸¸,ø¤
Richard Shaw
Technical Design Authority - Information Solutions Consultancy
Intelligent Transport Systems
Atkins Highways and Transportation
Woodcote Grove, Ashley Road, Epsom, Surrey, KT18 5BW
Tel: +44 (0) 1372 756407
Fax: +44 (0) 1372 740055
Mob: 07740 817586
E-mail: richard.shaw@atkinsglobal.com
www.atkinsglobal.com/its
This email and any attached files are confidential and copyright protected. If you are not the addressee, any dissemination of this communication is strictly prohibited. Unless otherwise expressly agreed in writing, nothing stated in this communication shall be legally binding.
The ultimate parent company of the Atkins Group is WS Atkins plc. Registered in England No. 1885586. Registered Office Woodcote Grove, Ashley Road, Epsom, Surrey KT18 5BW. A list of wholly owned Atkins Group companies registered in the United Kingdom can be found at http://www.atkinsglobal.com/terms_and_conditions/index.aspx
Consider the environment. Please don't print this e-mail unless you really need to.
Re: JAXB substitutionGroups
Posted by Daniel Kulp <dk...@apache.org>.
This is covered in the jaxb spec. (section 6.7.5, see example 6-14) In
sort, there isn't a way. The main reason is that the subclasses of
AbstractFeatureType may not (actually, per spec, they WON'T) have
XmlRootElement declarations on them so the runtime would have idea what
the qname of the elements to write out will be.
According to spec, you should use the ObjectFactory methods to create the
JAXBElement objects with the correct qnames+values.
From the jaxb spec example, the factory should have methods like:
// Element Instance Factories
JAXBElement<AutoType> createAuto(AutoType value);
JAXBElement<PlaneType> createPlane(PlaneType value);
JAXBElement<TransportType> createTrain(TransportType value);
Dan
On Thursday 03 April 2008, Shaw, Richard A wrote:
> Does anybody know why XSD substitutionGroups cause JAXB to create code
> like the following -
>
> List<JAXBElement<? Extends AbstractFeatureType> > features;
>
> Why isn't it simply -
>
> List<AbstractFeatureType> features;
>
> Is there any way to change it ? I searched the web and couldn't find
> anything.
>
> Richard Shaw
>
> ¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø¤º°`°º¤ø,¸¸,ø¤
>
> Richard Shaw
> Technical Design Authority - Information Solutions Consultancy
> Intelligent Transport Systems
>
> Atkins Highways and Transportation
> Woodcote Grove, Ashley Road, Epsom, Surrey, KT18 5BW
>
> Tel: +44 (0) 1372 756407
> Fax: +44 (0) 1372 740055
> Mob: 07740 817586
> E-mail: richard.shaw@atkinsglobal.com
>
> www.atkinsglobal.com/its
>
>
>
> This email and any attached files are confidential and copyright
> protected. If you are not the addressee, any dissemination of this
> communication is strictly prohibited. Unless otherwise expressly
> agreed in writing, nothing stated in this communication shall be
> legally binding.
>
> The ultimate parent company of the Atkins Group is WS Atkins plc.
> Registered in England No. 1885586. Registered Office Woodcote Grove,
> Ashley Road, Epsom, Surrey KT18 5BW. A list of wholly owned Atkins
> Group companies registered in the United Kingdom can be found at
> http://www.atkinsglobal.com/terms_and_conditions/index.aspx
>
> Consider the environment. Please don't print this e-mail unless you
> really need to.
--
J. Daniel Kulp
Principal Engineer, IONA
dkulp@apache.org
http://www.dankulp.com/blog