Say I have three schemas: main.xsd, common1.xsd, and common2.xsd.
common1 and common2 already have their own predefined packages containing jaxb objects.
main.xsd imports both common1.xsd and common2.xsd.
When I attempt to generate the jaxb objects for main.xsd, it of course generates all of the objects it refers to via common1 and common2, but to the package main which leads to my problem. Now, when I attempt to set data to an element from main containing references to common1 or common2 in the java code, I of course get the error that common1.element does not match main.element.
Ex) In my java code:
common1.ObjectFactory.getExData() will return common.ExData. main.setExData(ExDataType exampleData) will expect ExDataType from the package main. But I get this data from the ObjectFactory in common1, so it refers to common1.ExDataType
My question is, how do I generate these objects for main in a way that I don't duplicate types created in the main package and they instead refer to the existing common1 or common2 objects?
EDIT
Episode files seemed to be the way to go, so I attempted this route.
I first ran the command to generate the episode files for each of my imported schemas using the command supplied by Blaise's answer(but with my filenames/paths substituted):
xjc -d out -episode product.episode Product.xsd
Then I attempted to run the command to generate the JAXB classes for the schema containing these imports using the next command:
xjc -d out ProductPurchaseRequest.xsd -extension -b product.episode
The first command seemed to just generate all of the class files for the "product.xsd" to where I specified in the out parameter, and I don't see an "product.episode" file anywhere. The second command created a new package for each schema it referenced, then created all of the object classes for them in each, but they all contained the wrong package reference and it was quiet messy.
What am I missing in how I ran these commands?