users@jaxb.java.net

Re: changing package names in a Plugin

From: Andreas Pakulat <pakulat_at_rostock.zgdv.de>
Date: Tue, 28 Mar 2006 01:56:26 +0200

On 27.03.06 10:55:47, Kohsuke Kawaguchi wrote:
> Andreas Pakulat wrote:
> >Hi,
> >I'm struggling a bit here with writing a Plugin for xjc. My goal is to prefix
> >all generated package names (created from the targetNamespace) with my own
> >package, so that I end up with a structure like
> >my.company.some.namespace
> >I started with the Camelcase Plugin as this one changes the class name and
> >changed the NameConverter.Standard subclass to return some arbitrary string
> >for toPackageName(). However it seems like my plugin isn't used at all.
>
> As Malachi responded, I think the best thing to do would be to use a
> customization.
>
> If you would still like to pursue a plugin approach, let me know so that we can
> think about changing XJC a bit to let you do that.

It seems my answer to Malachi got lost. So here I go again:

I'm trying to parse a whole lot of schema files. I have about 2-5
"entry" schema files, which I will give to jaxb. Everyone might
reference other schema files via xs:include or xs:import and those might
have different targetNamespaces. If I'm not totally mistaken I have
about 4 or 5 different namespaces. The problem here is I'd have to
figure out which "other" schema file is first imported from an entry
schema file for a particular namespace. I'd also have to have different
binding files for each entry-schema file as each might use another
schema file as first one for a particular namespace.

Now regarding the -p commandline option: That one totaly "disables" the
automatic package-generation-from-namespaces which doesn't work either
as I then get many collisions because classes are named the same in
various namespaces.

Thus I thought overriding the toPackageName(String s) function of a
NameConverter would help here, however it seems that this method is
never called??

So what I'm looking for is just a way to prefix every generated
packagename with another package string to make the inclusion into the
project I'm working on easier (I can probably do with refactoring, but
that just feels wrong).

Andreas

-- 
Today is the first day of the rest of your life.