users@jaxb.java.net

Re: Reusing bindings from previous xjc run

From: Malachi de AElfweald <malachi_at_eoti.org>
Date: Fri, 29 Oct 2004 23:38:34 -0700

At 08:29 AM 10/25/2004, Ryan Shoemaker - JavaSoft East wrote:
>Lachlan O'Dea wrote:
>>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.
>
>This would be my recommendation. You should be able to regenerate
>the bindings for A.xsd by compiling B.xsd without impacting your
>existing client apps. Can you elaborate on why you think this won't
>work?
>
>>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.
>
>This sounds like the wrong approach.

Now that I have moved from Ant to Maven, I am having the same issue.

Basically, I used to have a single XSD that contained common complexTypes
that the other XSDs imported. At the time, it was no big deal since all the
schema bindings were being built at the same time.

Now, however, Maven builds the common library first (containing the
bindings for that common XSD) and then adds it to the classpath for the
next module.

What I WANT to happen is to be able to tell JAXB that any references to
"eu:paramConfig" should be implemented by the previously built impl.

What it is currently doing is creating another copy (in a separate
jar). That doesn't really work because the whole point of the common
library is that common utility classes handle those objects. They don't
know anything about the classes in the new jar.

I will email back if I find a clean way of doing it -- but I think what we
want to do is provide some kind of annotation instead of doing an xsd:import.


Malachi



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
For additional commands, e-mail: users-help_at_jaxb.dev.java.net