users@jaxb.java.net

Re: Duplicate classes and schema types

From: Xavier Callejas <xavier_at_wflogistics.com>
Date: Tue, 11 Jan 2011 10:21:41 -0600

On Mar 11 Ene 2011 10:10:47 Kevin and Louise . escribió:
> Hi,
>
> I have a number of schemas that include some common types - hence when I
> run xjc on them I get the same classes repeated in different packages. If
> I run the compilation on all schemas at once xjc complains about duplicate
> classes. If I pull them all out into a common.xsd schema and include that
> in the others then I think that would solve the problem but I would like
> to avoid changing the schemas if possible. Anyone know of a good way to
> provide a generic interface to these duplicate generated classes that
> doesn't involve schema changes/editing the classes? Or a way of only
> generating one of each duplicated type?
> Cheers.

You could use JAXB customizing:

http://download.oracle.com/docs/cd/E17802_01/webservices/webservices/docs/1.5/tutorial/doc/JAXBUsing4.html

I have used this when I do not want to duplicate the model classes, too. For
example, I have a .jar containing JPA entity classes that I will use also in
the client, I use the same .jar in the server but also in the client, I must
tell, for example, to JAX-WS to use the existing classes when compiling a web
server client.

I have not done this in a while so I cannot tell you in more details.

Regards.

Xavier.