users@jaxb.java.net

Reusing bindings from previous xjc run

From: Lachlan O'Dea <odela01_at_ca.com>
Date: Tue, 19 Oct 2004 19:30:11 +1000

Hi, I've been having trouble making xjc do what I want.

Say I have a utility library that uses XML schema A. My build runs xjc
and puts everything into a jar. This jar is then used by a variety of
applications.

One application uses XML schema B, which imports schema A as a
namespace. The problem is that when I run xjc over schema B, it goes
and regenerates all the schema A bindings. I would like the generated
schema B bindings to just reuse the schema A bindings that already
exist.

I tried using the same namespace and package names for the schema A
stuff in both places, then ignoring the second lot of generated schema
A bindings. It doesn't seem to work though. The Schema B bindings seem
to be tied to the internals of the schema A bindings, so that they
don't work with the classes in the utility jar.

Any suggestions on how to do this? All I've found is the advice
"generate all your bindings in a single xjc invocation". That doesn't
really work here, since I'm reusing a jar that has already been built.

The brute force option is to put the schema A bindings in a different
package on the second run. I duplicate a whole bunch of code, but it
should work. The problem there is that any code written to use the
bindings can't work with both versions. I'd have to duplicate that code
too.

I hope all this is making sense.

--
Lachlan O'Dea
Computer Associates
Senior Software Engineer
tel: +61 3 8416 5627
fax: +61 3 8416 5810
mobile: +61 412 390 650
odela01_at_ca.com
Relax and enjoy your shoes!