users@jaxb.java.net

Re: Unable to apply a customisation in a multiple compilation scenario

From: Aleksei Valikov <valikov_at_gmx.net>
Date: Fri, 6 Jun 2008 13:51:59 +0200

Hi.

>> See SimpleTypeBuilder, how and where it's called for further clues.
>
> I'll take a look, thanks. This may be related to the problems that JAXB has
> with enums, which also don't work with episodes. In general, the episode
> code seems to be extremely fragile.

Well, not THAT fragile.. "Episodes" are in practice just
customizations attached via SCD. Some of the customizations don't work
fine, that's true. But at the end with some effort it works.

>> ps. Another trick I sometimes apply is generate the code and then
>> explicitly delete it if I don't need it.
>
> This might be worth looking at for us. Can you elaborate a bit more? Doesn't
> the generated code then have the imports incorrect since the objects are in
> different packages?

No, if you use customizations or episodes to specify correct package names.

If you want to see examples, there's a relatively large
http://ogc.dev.java.net project which compiles ~60 schemas in
different modules - and it does a lot of separate/episodic
compilation. I've also had problems with episodic compilation. For
instance, in some cases XJC generates classes even if namespace is not
mapped. In these cases I had to remove "leftover" files explicitly.
Another problem is that episode files generated by XJC have usually
something like:

  <bindings scd="x-schema::tns" xmlns:tns="http://www.opengis.net/gml">
    <schemaBindings map="false"/>
...
  </bindings>

This should be:

  <bindings scd="x-schema::tns" xmlns:tns="http://www.opengis.net/gml">
    <schemaBindings map="false">
        <package name="net.opengis.gml.v_3_1_1"/>
    </schemaBindings>
...
  </bindings>

in case you provide a custom package name (net.opengis.gml.v_3_1_1).
With the first episode file XJC sometimes generates classes in the
"default" package (net.opengis.gml) instead of the customized one
(net.opengis.gml.v_3_1_1).
To resolve this provblem I usually generate an episode file once
automatically, correct it, include in the distribution and turn off
automatic episode generation.

See https://ogc.dev.java.net/svn/ogc/trunk/wfs/1.1.0/schema/ for example.

Bye.
/lexi